From b5fb59a84eb69e5ce25ce08da5872054ab2a1817 Mon Sep 17 00:00:00 2001 From: Simon Rodriguez Date: Wed, 26 Aug 2020 21:51:45 +0200 Subject: [PATCH] Added OpenOnCreate settings. (#295) Adds the option to prevent opening the graph editor when creating a new graph. Suggested in Issues #286 --- Scripts/Editor/NodeEditorPreferences.cs | 2 ++ Scripts/Editor/NodeEditorWindow.cs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Scripts/Editor/NodeEditorPreferences.cs b/Scripts/Editor/NodeEditorPreferences.cs index 72eb8aa..e5fa238 100644 --- a/Scripts/Editor/NodeEditorPreferences.cs +++ b/Scripts/Editor/NodeEditorPreferences.cs @@ -35,6 +35,7 @@ namespace XNodeEditor { public Color32 highlightColor = new Color32(255, 255, 255, 255); public bool gridSnap = true; public bool autoSave = true; + public bool openOnCreate = true; public bool dragToCreate = true; public bool zoomToMouse = true; public bool portTooltips = true; @@ -149,6 +150,7 @@ namespace XNodeEditor { //Label EditorGUILayout.LabelField("System", EditorStyles.boldLabel); settings.autoSave = EditorGUILayout.Toggle(new GUIContent("Autosave", "Disable for better editor performance"), settings.autoSave); + settings.openOnCreate = EditorGUILayout.Toggle(new GUIContent("Open Editor on Create", "Disable to prevent openening the editor when creating a new graph"), settings.openOnCreate); if (GUI.changed) SavePrefs(key, settings); EditorGUILayout.Space(); } diff --git a/Scripts/Editor/NodeEditorWindow.cs b/Scripts/Editor/NodeEditorWindow.cs index 4f0a102..a7ec96b 100644 --- a/Scripts/Editor/NodeEditorWindow.cs +++ b/Scripts/Editor/NodeEditorWindow.cs @@ -99,7 +99,7 @@ namespace XNodeEditor { private static void OnSelectionChanged() { XNode.NodeGraph nodeGraph = Selection.activeObject as XNode.NodeGraph; if (nodeGraph && !AssetDatabase.Contains(nodeGraph)) { - Open(nodeGraph); + if (NodeEditorPreferences.GetSettings().openOnCreate) Open(nodeGraph); } }