Jump to content

Use KSP default GUI Skin ?


Recommended Posts

A thing to remember is that if you change specific styles, like for example GUI.skin.label = HighLogic.Skin.label, it can have the side effect of changing the style on other windows than just yours.

I accidentally changed the style of the window of another mod because of this because I wanted some styles to remain the standard ones.

To avoid that I did this:


public void OnGUI()
{
this.InitializeStyles();
this.window = GUILayout.Window(258648, this.window, this.OnWindow, Texts.MainWindowTitle, HighLogic.Skin.window)
}

private void InitializeStyles()
{
if (!this.stylesInitialized)
{
this.stylesInitialized = true;
this.guiSkin = new GUISkin
{
button = GUI.skin.button,
label = HighLogic.Skin.label,
toggle = HighLogic.Skin.toggle
// And so on, including all styles you want
};
}
}

private void OnWindow(int id)
{
GUI.skin = this.guiSkin;
//Do GUI stuff....
GUI.skin = null;
}

Edited by Uzza
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...