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

Commit e5b9298

Browse files
committed
v1.0.2. GUI Fixes
Fixed missing EditorStyles in GUISkin, so errors would be thrown when EditorGUI was used in NodeInspector Fixed EditorGUI controls using default text color and thus not fitting into the custom style by temporarily changing EditorStyles - Should be bugfree, critical as they can potentially mess the whole Editor GUI up Changed RTNodeEditor to use normal EditorGUI controls when in the EditorWindow and only fall back to custom controls in play mode Changed GUI texture properties to be consistent
1 parent 98a676a commit e5b9298

File tree

13 files changed

+122
-70
lines changed

13 files changed

+122
-70
lines changed

Editor/NodeInspector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public override void OnInspectorGUI()
6161
GUILayout.Space(10);
6262

6363
GUILayout.Label("Property Editor", boldLabelStyle);
64-
node.DrawNodePropertyEditor();
64+
node.DrawNodePropertyEditor(true);
6565

6666
if (EditorGUI.EndChangeCheck())
6767
NodeEditor.RepaintClients();

Runtime/Framework/Core/Node.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,12 @@ public virtual void NodeGUI ()
122122
/// Used to display a custom node property editor in the GUI.
123123
/// By default shows the standard NodeGUI.
124124
/// </summary>
125-
public virtual void DrawNodePropertyEditor ()
125+
public virtual void DrawNodePropertyEditor (bool isEditorWindow = false)
126126
{
127127
try
128128
{ // Draw Node GUI without disturbing knob placement
129129
ignoreGUIKnobPlacement = true;
130-
NodeEditorGUI.StartNodeGUI(false);
130+
NodeEditorGUI.StartNodeGUI(isEditorWindow);
131131
GUILayout.BeginVertical(GUI.skin.box);
132132
NodeGUI();
133133
GUILayout.EndVertical();

Runtime/Framework/Interface/NodeEditorGUI.cs

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,18 @@ public static partial class NodeEditorGUI
1717

1818
public static Color NE_LightColor = new Color (0.4f, 0.4f, 0.4f);
1919
public static Color NE_TextColor = new Color(0.8f, 0.8f, 0.8f);
20+
public static Color NE_TextColorSelected = new Color(0.6f, 0.6f, 0.6f);
2021

2122
public static Texture2D Background;
2223
public static Texture2D AALineTex;
2324

2425
public static GUISkin nodeSkin { get { return overrideSkin ?? defaultSkin; } }
2526
public static GUISkin overrideSkin;
26-
public static GUISkin defaultSkin;
27-
public static GUISkin unitySkin;
27+
private static GUISkin defaultSkin;
28+
private static GUISkin unitySkin;
29+
30+
private static Color unityTextColor, unityHoverTextColor, unityActiveTextColor, unityFocusedTextColor;
31+
2832

2933
public static bool Init ()
3034
{
@@ -35,21 +39,22 @@ public static bool Init ()
3539
return CreateDefaultSkin();
3640
else {
3741
defaultSkin = Object.Instantiate (defaultSkin);
38-
3942
// Copy default editor styles, modified to fit custom style
40-
/*
41-
customStyles = new List<GUIStyle> (nodeSkin.customStyles);
43+
customStyles = new List<GUIStyle> (defaultSkin.customStyles);
4244
foreach (GUIStyle style in GUI.skin.customStyles)
4345
{
44-
if (nodeSkin.FindStyle(style.name) == null)
46+
if (defaultSkin.FindStyle(style.name) == null)
4547
{
4648
GUIStyle modStyle = new GUIStyle (style);
47-
modStyle.fontSize = nodeSkin.label.fontSize;
48-
modStyle.normal.textColor = modStyle.active.textColor = modStyle.focused.textColor = modStyle.hover.textColor = nodeSkin.label.normal.textColor;
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+
}
4954
customStyles.Add (modStyle);
5055
}
5156
}
52-
nodeSkin.customStyles = customStyles.ToArray();*/
57+
defaultSkin.customStyles = customStyles.ToArray();
5358

5459
Background = ResourceManager.LoadTexture ("Textures/background.png");
5560
AALineTex = ResourceManager.LoadTexture ("Textures/AALine.png");
@@ -158,7 +163,7 @@ public static bool CreateDefaultSkin ()
158163

159164
defaultSkin.customStyles = customStyles.ToArray();
160165
#if UNITY_EDITOR
161-
UnityEditor.AssetDatabase.CreateAsset(Object.Instantiate (nodeSkin), ResourceManager.resourcePath + "DefaultSkin.asset");
166+
UnityEditor.AssetDatabase.CreateAsset(Object.Instantiate (defaultSkin), ResourceManager.resourcePath + "DefaultSkin.asset");
162167
#endif
163168

164169
return true;
@@ -167,16 +172,36 @@ public static bool CreateDefaultSkin ()
167172
public static void StartNodeGUI (bool IsEditorWindow)
168173
{
169174
NodeEditor.checkInit(true);
175+
// Required for gamemode switch
176+
// Also for EditorWindow+RTNodeEditor in parallel where RTNodeEditor GUISkin setup would not be enough for the editor window as it's missing the editor styles
177+
if (nodeSkin == null || (IsEditorWindow && nodeSkin.FindStyle("ObjectField") == null))
178+
NodeEditor.ReInit(true);
170179

171180
isEditorWindow = IsEditorWindow;
172181

173182
unitySkin = GUI.skin;
174183
GUI.skin = nodeSkin;
184+
#if UNITY_EDITOR
185+
unityTextColor = UnityEditor.EditorStyles.label.normal.textColor;
186+
UnityEditor.EditorStyles.label.normal.textColor = NE_TextColor;
187+
unityHoverTextColor = UnityEditor.EditorStyles.label.hover.textColor;
188+
UnityEditor.EditorStyles.label.hover.textColor = NE_TextColor;
189+
unityActiveTextColor = UnityEditor.EditorStyles.label.active.textColor;
190+
UnityEditor.EditorStyles.label.active.textColor = NE_TextColorSelected;
191+
unityFocusedTextColor = UnityEditor.EditorStyles.label.focused.textColor;
192+
UnityEditor.EditorStyles.label.focused.textColor = NE_TextColorSelected;
193+
#endif
175194
}
176195

177196
public static void EndNodeGUI ()
178197
{
179198
GUI.skin = unitySkin;
199+
#if UNITY_EDITOR
200+
UnityEditor.EditorStyles.label.normal.textColor = unityTextColor;
201+
UnityEditor.EditorStyles.label.hover.textColor = unityHoverTextColor;
202+
UnityEditor.EditorStyles.label.active.textColor = unityActiveTextColor;
203+
UnityEditor.EditorStyles.label.focused.textColor = unityFocusedTextColor;
204+
#endif
180205
}
181206

182207
#region Connection Drawing

Runtime/Resources/Textures/NE_Box.png.meta

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Resources/Textures/NE_Button.png.meta

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Resources/Textures/NE_Button_Hover.png.meta

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Resources/Textures/NE_Button_Selected.png.meta

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Resources/Textures/NE_SelectedBG.png.meta

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Resources/Textures/NE_Toolbar.png.meta

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Resources/Textures/NE_ToolbarButton.png.meta

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)