1
0
mirror of https://github.com/Siccity/xNode.git synced 2026-03-26 22:49:02 +08:00

Made the feature work eveen when no node editor is currently open

This commit is contained in:
Thor Brigsted 2019-04-03 20:34:07 +02:00
parent 00ca95b452
commit 6e498e8b93

View File

@ -70,9 +70,15 @@ namespace XNodeEditor {
if (graphEditor != null && NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets(); if (graphEditor != null && NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
} }
[InitializeOnLoadMethod]
private static void OnLoad() {
Selection.selectionChanged -= OnSelectionChanged;
Selection.selectionChanged += OnSelectionChanged;
}
/// <summary> Handle Selection Change events</summary> /// <summary> Handle Selection Change events</summary>
private void OnSelectionChange() { private static void OnSelectionChanged() {
var nodeGraph = Selection.activeObject as XNode.NodeGraph; XNode.NodeGraph nodeGraph = Selection.activeObject as XNode.NodeGraph;
if (nodeGraph && !AssetDatabase.Contains(nodeGraph)) { if (nodeGraph && !AssetDatabase.Contains(nodeGraph)) {
Open(nodeGraph); Open(nodeGraph);
} }
@ -163,8 +169,7 @@ namespace XNodeEditor {
/// <summary>Open the provided graph in the NodeEditor</summary> /// <summary>Open the provided graph in the NodeEditor</summary>
public static void Open(XNode.NodeGraph graph) { public static void Open(XNode.NodeGraph graph) {
if (!graph) if (!graph) return;
return;
NodeEditorWindow w = GetWindow(typeof(NodeEditorWindow), false, "xNode", true) as NodeEditorWindow; NodeEditorWindow w = GetWindow(typeof(NodeEditorWindow), false, "xNode", true) as NodeEditorWindow;
w.wantsMouseMove = true; w.wantsMouseMove = true;