From 3ba566cf3311e163ca0b776367adb3988e5413d7 Mon Sep 17 00:00:00 2001 From: Megalon Date: Sun, 28 Nov 2021 21:21:44 -0800 Subject: [PATCH] Draw all nodes once on load to fix missing noodles --- Scripts/Editor/NodeEditorGUI.cs | 7 +++++-- Scripts/Editor/NodeEditorWindow.cs | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Scripts/Editor/NodeEditorGUI.cs b/Scripts/Editor/NodeEditorGUI.cs index 70c4cd1..577ed95 100755 --- a/Scripts/Editor/NodeEditorGUI.cs +++ b/Scripts/Editor/NodeEditorGUI.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using UnityEditor; @@ -439,7 +439,8 @@ namespace XNodeEditor { // Culling if (e.type == EventType.Layout) { // Cull unselected nodes outside view - if (!Selection.Contains(node) && ShouldBeCulled(node)) { + if (drewAllNodesOnLoad && !Selection.Contains(node) && ShouldBeCulled(node)) + { culledNodes.Add(node); continue; } @@ -551,6 +552,8 @@ namespace XNodeEditor { //This is done through reflection because OnValidate is only relevant in editor, //and thus, the code should not be included in build. if (onValidate != null && EditorGUI.EndChangeCheck()) onValidate.Invoke(Selection.activeObject, null); + + drewAllNodesOnLoad = true; } private bool ShouldBeCulled(XNode.Node node) { diff --git a/Scripts/Editor/NodeEditorWindow.cs b/Scripts/Editor/NodeEditorWindow.cs index a7ec96b..1ad0b1b 100644 --- a/Scripts/Editor/NodeEditorWindow.cs +++ b/Scripts/Editor/NodeEditorWindow.cs @@ -16,6 +16,8 @@ namespace XNodeEditor { [SerializeField] private NodePortReference[] _references = new NodePortReference[0]; [SerializeField] private Rect[] _rects = new Rect[0]; + private static bool drewAllNodesOnLoad = false; + private Func isDocked { get { if (_isDocked == null) _isDocked = this.GetIsDockedDelegate(); @@ -199,6 +201,8 @@ namespace XNodeEditor { public static NodeEditorWindow Open(XNode.NodeGraph graph) { if (!graph) return null; + drewAllNodesOnLoad = false; + NodeEditorWindow w = GetWindow(typeof(NodeEditorWindow), false, "xNode", true) as NodeEditorWindow; w.wantsMouseMove = true; w.graph = graph;