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

Commit b31fa9b

Browse files
committed
LTS v1.0.3. GUI Fixes, editor scaling support
- Fixed RTNodeEditor example having no root rect and thus context menus not appearing - Fixed broken GUI when using 2019.3+ Editor Scaling feature - Fixed spelling mistake ForceGUIDawOffScreen -> ForceGUIDrawOffScreen in Node.cs - Changed toolbar information, made it more compact - Moved standard NodeEditorFramework.Standard.NodeEditorInterface to the Standard folder where it belongs
1 parent e5b9298 commit b31fa9b

File tree

11 files changed

+425
-367
lines changed

11 files changed

+425
-367
lines changed

Editor/NodeEditorWindow.cs

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

269269
// Draw Interface
270-
editorInterface.DrawToolbarGUI(new Rect(0, 0, Screen.width, 0));
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));
271276
editorInterface.DrawModalPanel();
272277

273278
// End Node Editor GUI

Editor/Seneral.NodeEditorFramework.Editor.asmdef

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"name": "Seneral.NodeEditorFramework.Editor",
33
"references": [
4-
"GUID:984eb8b4fce069a4fb617d10374722b2"
4+
"GUID:984eb8b4fce069a4fb617d10374722b2",
5+
"GUID:c7dd23d8a26985747bf8c6284ac6b26f"
56
],
67
"includePlatforms": [
78
"Editor"

Runtime/Framework/Core/Node.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public virtual string Title { get {
8484
/// <summary>
8585
/// Specifies whether GUI requires to be updated even when the node is off-screen
8686
/// </summary>
87-
public virtual bool ForceGUIDawOffScreen { get { return false; } }
87+
public virtual bool ForceGUIDrawOffScreen { get { return false; } }
8888

8989
#endregion
9090

Runtime/Framework/Interface/NodeEditorGUI.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ public static bool CreateDefaultSkin ()
106106
// Box
107107
defaultSkin.box.normal.background = GUIBox;
108108
defaultSkin.box.normal.textColor = NE_TextColor;
109+
#if UNITY_EDITOR && UNITY_2019_3_OR_NEWER
110+
defaultSkin.box.normal.scaledBackgrounds = null;
111+
#endif
109112
defaultSkin.box.active.textColor = NE_TextColor;
110113
customStyles.Add(new GUIStyle (defaultSkin.box) { name = "boxBold", fontStyle = FontStyle.Bold });
111114

@@ -114,6 +117,11 @@ public static bool CreateDefaultSkin ()
114117
defaultSkin.button.normal.background = GUIButton;
115118
defaultSkin.button.hover.background = GUIButtonHover;
116119
defaultSkin.button.active.background = GUIButtonSelected;
120+
#if UNITY_EDITOR && UNITY_2019_3_OR_NEWER
121+
defaultSkin.button.normal.scaledBackgrounds = null;
122+
defaultSkin.button.hover.scaledBackgrounds = null;
123+
defaultSkin.button.active.scaledBackgrounds = null;
124+
#endif
117125
defaultSkin.button.border = new RectOffset(1, 1, 1, 1);
118126
defaultSkin.button.margin = new RectOffset(2, 2, 1, 1);
119127
defaultSkin.button.padding = new RectOffset(4, 4, 1, 1);
@@ -132,6 +140,10 @@ public static bool CreateDefaultSkin ()
132140
GUIStyle toolbar = new GUIStyle(defaultSkin.box) { name = "toolbar" };
133141
toolbar.normal.background = GUIToolbar;
134142
toolbar.active.background = GUIToolbar;
143+
#if UNITY_EDITOR && UNITY_2019_3_OR_NEWER
144+
toolbar.normal.scaledBackgrounds = null;
145+
toolbar.active.scaledBackgrounds = null;
146+
#endif
135147
toolbar.border = new RectOffset(0, 0, 1, 1);
136148
toolbar.margin = new RectOffset(0, 0, 0, 0);
137149
toolbar.padding = new RectOffset(1, 1, 1, 1);
@@ -140,14 +152,16 @@ public static bool CreateDefaultSkin ()
140152

141153
GUIStyle toolbarLabel = new GUIStyle(defaultSkin.box) { name = "toolbarLabel" };
142154
toolbarLabel.normal.background = GUIToolbarLabel;
155+
#if UNITY_EDITOR && UNITY_2019_3_OR_NEWER
156+
toolbarLabel.normal.scaledBackgrounds = null;
157+
#endif
143158
toolbarLabel.border = new RectOffset(2, 2, 0, 0);
144159
toolbarLabel.margin = new RectOffset(0, 0, 0, 0);
145160
toolbarLabel.padding = new RectOffset(6, 6, 2, 2);
146161
customStyles.Add(toolbarLabel);
147162

148163
GUIStyle toolbarButton = new GUIStyle(toolbarLabel) { name = "toolbarButton" };
149164
toolbarButton.normal.background = GUIToolbarButton;
150-
toolbarButton.border = new RectOffset(2, 2, 0, 0);
151165
toolbarButton.active.background = GUISelectedBG;
152166
customStyles.Add(toolbarButton);
153167

Runtime/Framework/NodeEditor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ private static void DrawSubCanvas (NodeCanvas nodeCanvas, NodeEditorState editor
249249
if (node == null) continue;
250250
if (Event.current.type == EventType.Layout)
251251
node.isClipped = !curEditorState.canvasViewport.Overlaps(node.fullAABBRect);
252-
if (!node.isClipped || node.ForceGUIDawOffScreen)
252+
if (!node.isClipped || node.ForceGUIDrawOffScreen)
253253
{
254254
node.DrawNode();
255255
if (Event.current.type == EventType.Repaint)

0 commit comments

Comments
 (0)