Skip to content
This repository was archived by the owner on Oct 31, 2023. It is now read-only.

Commit 768b0e6

Browse files
committed
LTS v1.0.3 UI fixes
Fixed #189 toolbar not showing up introduced in f82311c (v1.0.3) Improved GUISkin handling so that the default GUIStyle are always used - Fixes some problems with missing styles at Runtime if not explicitly set, as well as issues when switching between dark and light modes - New behaviour: Always generate DefaultSkin and save to file for user to copy and modify. If OverriddenSkin.asset exists, use that style as a basis instead. Fixed issue with XML IO for objects that can not be serialized (e.g. Texture2D in TextureCompose example)
1 parent b31fa9b commit 768b0e6

File tree

7 files changed

+40
-2214
lines changed

7 files changed

+40
-2214
lines changed

Editor/NodeEditorWindow.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -267,12 +267,7 @@ private void OnGUI()
267267
}
268268

269269
// Draw Interface
270-
float screenWidth = Screen.width;
271-
#if UNITY_EDITOR && UNITY_2019_3_OR_NEWER
272-
float scaling = UnityEditor.EditorPrefs.GetInt("CustomEditorUIScale") / 100.0f;
273-
screenWidth = screenWidth / scaling;
274-
#endif
275-
editorInterface.DrawToolbarGUI(new Rect(0, 0, screenWidth, 0));
270+
editorInterface.DrawToolbarGUI();
276271
editorInterface.DrawModalPanel();
277272

278273
// End Node Editor GUI

Runtime/Framework/Interface/NodeEditorGUI.cs

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,35 +32,40 @@ public static partial class NodeEditorGUI
3232

3333
public static bool Init ()
3434
{
35-
List<GUIStyle> customStyles = new List<GUIStyle> ();
35+
overrideSkin = ResourceManager.LoadResource<GUISkin> ("OverrideSkin.asset");
36+
if (overrideSkin == null)
37+
{ // Create default skin from scratch
38+
if (!CreateDefaultSkin ()) return false;
39+
overrideSkin = Object.Instantiate (defaultSkin);
40+
}
41+
else
42+
{ // Use override
43+
overrideSkin = Object.Instantiate (overrideSkin);
44+
}
45+
46+
// Copy default styles in current setting, modified to fit custom style
47+
// This mostly refers to the editor styles
3648

37-
defaultSkin = ResourceManager.LoadResource<GUISkin> ("DefaultSkin.asset");
38-
if (defaultSkin == null)
39-
return CreateDefaultSkin();
40-
else {
41-
defaultSkin = Object.Instantiate (defaultSkin);
42-
// Copy default editor styles, modified to fit custom style
43-
customStyles = new List<GUIStyle> (defaultSkin.customStyles);
44-
foreach (GUIStyle style in GUI.skin.customStyles)
49+
List<GUIStyle> customStyles = new List<GUIStyle> (overrideSkin.customStyles);
50+
foreach (GUIStyle style in GUI.skin.customStyles)
51+
{
52+
if (overrideSkin.FindStyle(style.name) == null)
4553
{
46-
if (defaultSkin.FindStyle(style.name) == null)
54+
GUIStyle modStyle = new GUIStyle (style);
55+
if (modStyle.normal.background == null)
4756
{
48-
GUIStyle modStyle = new GUIStyle (style);
49-
if (modStyle.normal.background == null)
50-
{
51-
modStyle.fontSize = defaultSkin.label.fontSize;
52-
modStyle.normal.textColor = modStyle.active.textColor = modStyle.focused.textColor = modStyle.hover.textColor = defaultSkin.label.normal.textColor;
53-
}
54-
customStyles.Add (modStyle);
57+
modStyle.fontSize = overrideSkin.label.fontSize;
58+
modStyle.normal.textColor = modStyle.active.textColor = modStyle.focused.textColor = modStyle.hover.textColor = overrideSkin.label.normal.textColor;
5559
}
60+
customStyles.Add (modStyle);
5661
}
57-
defaultSkin.customStyles = customStyles.ToArray();
58-
59-
Background = ResourceManager.LoadTexture ("Textures/background.png");
60-
AALineTex = ResourceManager.LoadTexture ("Textures/AALine.png");
61-
62-
return Background && AALineTex;
6362
}
63+
overrideSkin.customStyles = customStyles.ToArray();
64+
65+
Background = ResourceManager.LoadTexture ("Textures/background.png");
66+
AALineTex = ResourceManager.LoadTexture ("Textures/AALine.png");
67+
68+
return Background && AALineTex;
6469
}
6570

6671
public static bool CreateDefaultSkin ()
@@ -177,7 +182,8 @@ public static bool CreateDefaultSkin ()
177182

178183
defaultSkin.customStyles = customStyles.ToArray();
179184
#if UNITY_EDITOR
180-
UnityEditor.AssetDatabase.CreateAsset(Object.Instantiate (defaultSkin), ResourceManager.resourcePath + "DefaultSkin.asset");
185+
if (!ResourceManager.resourcePath.StartsWith("Packages"))
186+
UnityEditor.AssetDatabase.CreateAsset(Object.Instantiate (defaultSkin), ResourceManager.resourcePath + "DefaultSkin.asset");
181187
#endif
182188

183189
return true;

0 commit comments

Comments
 (0)