From 5597e565d124751c0c836d0b44f50644a1249a9c Mon Sep 17 00:00:00 2001 From: Thor Brigsted Date: Mon, 23 Dec 2019 13:56:49 +0100 Subject: [PATCH] Added focus selected node --- Scripts/Editor/GraphAndNodeEditor.cs | 3 ++- Scripts/Editor/NodeEditorWindow.cs | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Scripts/Editor/GraphAndNodeEditor.cs b/Scripts/Editor/GraphAndNodeEditor.cs index 6b4f12d..bfc809a 100644 --- a/Scripts/Editor/GraphAndNodeEditor.cs +++ b/Scripts/Editor/GraphAndNodeEditor.cs @@ -32,7 +32,8 @@ namespace XNodeEditor { if (GUILayout.Button("Edit graph", GUILayout.Height(40))) { SerializedProperty graphProp = serializedObject.FindProperty("graph"); - NodeEditorWindow.Open(graphProp.objectReferenceValue as XNode.NodeGraph); + NodeEditorWindow w = NodeEditorWindow.Open(graphProp.objectReferenceValue as XNode.NodeGraph); + w.Home(); // Focus selected node } GUILayout.Space(EditorGUIUtility.singleLineHeight); diff --git a/Scripts/Editor/NodeEditorWindow.cs b/Scripts/Editor/NodeEditorWindow.cs index a063410..1f64653 100644 --- a/Scripts/Editor/NodeEditorWindow.cs +++ b/Scripts/Editor/NodeEditorWindow.cs @@ -187,12 +187,13 @@ namespace XNodeEditor { } /// Open the provided graph in the NodeEditor - public static void Open(XNode.NodeGraph graph) { - if (!graph) return; + public static NodeEditorWindow Open(XNode.NodeGraph graph) { + if (!graph) return null; NodeEditorWindow w = GetWindow(typeof(NodeEditorWindow), false, "xNode", true) as NodeEditorWindow; w.wantsMouseMove = true; w.graph = graph; + return w; } /// Repaint all open NodeEditorWindows.