Skip to content

Commit

Permalink
Use Object.Instantiate to copy Skin. Util function is suspect, and is…
Browse files Browse the repository at this point in the history
… copying the whole GUIStyles too, unnecessarily in this case.

Save and restore GUISkin around GUI operation (because other GUI might not set anything, eg. dev console).
  • Loading branch information
WazWaz committed Dec 13, 2016
1 parent 172b020 commit 42839fb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/kOS/Suffixed/Widget/GUIWidgets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ public class GUIWidgets : Box, IKOSScopeObserver

public GUIWidgets(int width, int height, SharedObjects shared) : base(Box.LayoutMode.Vertical,new WidgetStyle(new GUIStyle(HighLogic.Skin.window)))
{
var gskin = Utils.GetSkinCopy(HighLogic.Skin);
var gskin = UnityEngine.Object.Instantiate(HighLogic.Skin);

// Use Arial as that's what used in other KSP GUIs
gskin.font = WidgetStyle.FontNamed("Arial");

// Get back the style we made in the base initializer.
gskin.window = ReadOnlyStyle;
Expand Down Expand Up @@ -93,8 +96,10 @@ public GUIWidgets(int width, int height, SharedObjects shared) : base(Box.Layout

public override void DoGUI()
{
var prevSkin = GUI.skin;
GUI.skin = Skin.Skin;
base.DoGUI();
GUI.skin = prevSkin;
}

private void InitializeSuffixes()
Expand Down

0 comments on commit 42839fb

Please sign in to comment.