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

Commit

Permalink
LTS v1.0.3. GUI Fixes, editor scaling support
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
Seneral committed May 10, 2020
1 parent e5b9298 commit b31fa9b
Show file tree
Hide file tree
Showing 11 changed files with 425 additions and 367 deletions.
7 changes: 6 additions & 1 deletion Editor/NodeEditorWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,12 @@ private void OnGUI()
}

// Draw Interface
editorInterface.DrawToolbarGUI(new Rect(0, 0, Screen.width, 0));
float screenWidth = Screen.width;
#if UNITY_EDITOR && UNITY_2019_3_OR_NEWER
float scaling = UnityEditor.EditorPrefs.GetInt("CustomEditorUIScale") / 100.0f;
screenWidth = screenWidth / scaling;
#endif
editorInterface.DrawToolbarGUI(new Rect(0, 0, screenWidth, 0));
editorInterface.DrawModalPanel();

// End Node Editor GUI
Expand Down
3 changes: 2 additions & 1 deletion Editor/Seneral.NodeEditorFramework.Editor.asmdef
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "Seneral.NodeEditorFramework.Editor",
"references": [
"GUID:984eb8b4fce069a4fb617d10374722b2"
"GUID:984eb8b4fce069a4fb617d10374722b2",
"GUID:c7dd23d8a26985747bf8c6284ac6b26f"
],
"includePlatforms": [
"Editor"
Expand Down
2 changes: 1 addition & 1 deletion Runtime/Framework/Core/Node.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public virtual string Title { get {
/// <summary>
/// Specifies whether GUI requires to be updated even when the node is off-screen
/// </summary>
public virtual bool ForceGUIDawOffScreen { get { return false; } }
public virtual bool ForceGUIDrawOffScreen { get { return false; } }

#endregion

Expand Down
16 changes: 15 additions & 1 deletion Runtime/Framework/Interface/NodeEditorGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ public static bool CreateDefaultSkin ()
// Box
defaultSkin.box.normal.background = GUIBox;
defaultSkin.box.normal.textColor = NE_TextColor;
#if UNITY_EDITOR && UNITY_2019_3_OR_NEWER
defaultSkin.box.normal.scaledBackgrounds = null;
#endif
defaultSkin.box.active.textColor = NE_TextColor;
customStyles.Add(new GUIStyle (defaultSkin.box) { name = "boxBold", fontStyle = FontStyle.Bold });

Expand All @@ -114,6 +117,11 @@ public static bool CreateDefaultSkin ()
defaultSkin.button.normal.background = GUIButton;
defaultSkin.button.hover.background = GUIButtonHover;
defaultSkin.button.active.background = GUIButtonSelected;
#if UNITY_EDITOR && UNITY_2019_3_OR_NEWER
defaultSkin.button.normal.scaledBackgrounds = null;
defaultSkin.button.hover.scaledBackgrounds = null;
defaultSkin.button.active.scaledBackgrounds = null;
#endif
defaultSkin.button.border = new RectOffset(1, 1, 1, 1);
defaultSkin.button.margin = new RectOffset(2, 2, 1, 1);
defaultSkin.button.padding = new RectOffset(4, 4, 1, 1);
Expand All @@ -132,6 +140,10 @@ public static bool CreateDefaultSkin ()
GUIStyle toolbar = new GUIStyle(defaultSkin.box) { name = "toolbar" };
toolbar.normal.background = GUIToolbar;
toolbar.active.background = GUIToolbar;
#if UNITY_EDITOR && UNITY_2019_3_OR_NEWER
toolbar.normal.scaledBackgrounds = null;
toolbar.active.scaledBackgrounds = null;
#endif
toolbar.border = new RectOffset(0, 0, 1, 1);
toolbar.margin = new RectOffset(0, 0, 0, 0);
toolbar.padding = new RectOffset(1, 1, 1, 1);
Expand All @@ -140,14 +152,16 @@ public static bool CreateDefaultSkin ()

GUIStyle toolbarLabel = new GUIStyle(defaultSkin.box) { name = "toolbarLabel" };
toolbarLabel.normal.background = GUIToolbarLabel;
#if UNITY_EDITOR && UNITY_2019_3_OR_NEWER
toolbarLabel.normal.scaledBackgrounds = null;
#endif
toolbarLabel.border = new RectOffset(2, 2, 0, 0);
toolbarLabel.margin = new RectOffset(0, 0, 0, 0);
toolbarLabel.padding = new RectOffset(6, 6, 2, 2);
customStyles.Add(toolbarLabel);

GUIStyle toolbarButton = new GUIStyle(toolbarLabel) { name = "toolbarButton" };
toolbarButton.normal.background = GUIToolbarButton;
toolbarButton.border = new RectOffset(2, 2, 0, 0);
toolbarButton.active.background = GUISelectedBG;
customStyles.Add(toolbarButton);

Expand Down
2 changes: 1 addition & 1 deletion Runtime/Framework/NodeEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ private static void DrawSubCanvas (NodeCanvas nodeCanvas, NodeEditorState editor
if (node == null) continue;
if (Event.current.type == EventType.Layout)
node.isClipped = !curEditorState.canvasViewport.Overlaps(node.fullAABBRect);
if (!node.isClipped || node.ForceGUIDawOffScreen)
if (!node.isClipped || node.ForceGUIDrawOffScreen)
{
node.DrawNode();
if (Event.current.type == EventType.Repaint)
Expand Down
Loading

0 comments on commit b31fa9b

Please sign in to comment.