1
0
mirror of https://github.com/Siccity/xNode.git synced 2025-12-20 01:06:01 +08:00

Added focus selected node

This commit is contained in:
Thor Brigsted 2019-12-23 13:56:49 +01:00
parent 1d43244a8f
commit 5597e565d1
2 changed files with 5 additions and 3 deletions

View File

@ -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);

View File

@ -187,12 +187,13 @@ namespace XNodeEditor {
}
/// <summary>Open the provided graph in the NodeEditor</summary>
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;
}
/// <summary> Repaint all open NodeEditorWindows. </summary>