From 42839fb30d1cc118260cb176206b9095e44233a5 Mon Sep 17 00:00:00 2001 From: WarwickAllison Date: Tue, 13 Dec 2016 16:56:36 +1000 Subject: [PATCH] Use Object.Instantiate to copy Skin. Util function is suspect, and is 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). --- src/kOS/Suffixed/Widget/GUIWidgets.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/kOS/Suffixed/Widget/GUIWidgets.cs b/src/kOS/Suffixed/Widget/GUIWidgets.cs index 0c7312712..abd0a5cca 100644 --- a/src/kOS/Suffixed/Widget/GUIWidgets.cs +++ b/src/kOS/Suffixed/Widget/GUIWidgets.cs @@ -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; @@ -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()