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

Handle selectiton change event

This commit is contained in:
Robin Neal 2019-04-02 11:50:23 +01:00
parent af0523db2d
commit 71c395371e

View File

@ -70,6 +70,17 @@ namespace XNodeEditor {
if (graphEditor != null && NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
}
/// <summary> Handle Selection Change events</summary>
private void OnSelectionChange() {
if (!EditorApplication.isPlaying)
return;
var nodeGraph = Selection.activeObject as XNode.NodeGraph;
if (nodeGraph) {
Open(nodeGraph);
}
}
/// <summary> Create editor window </summary>
public static NodeEditorWindow Init() {
NodeEditorWindow w = CreateInstance<NodeEditorWindow>();
@ -147,14 +158,21 @@ namespace XNodeEditor {
public static bool OnOpen(int instanceID, int line) {
XNode.NodeGraph nodeGraph = EditorUtility.InstanceIDToObject(instanceID) as XNode.NodeGraph;
if (nodeGraph != null) {
NodeEditorWindow w = GetWindow(typeof(NodeEditorWindow), false, "xNode", true) as NodeEditorWindow;
w.wantsMouseMove = true;
w.graph = nodeGraph;
Open(nodeGraph);
return true;
}
return false;
}
public static void Open(XNode.NodeGraph graph) {
if (!graph)
return;
NodeEditorWindow w = GetWindow(typeof(NodeEditorWindow), false, "xNode", true) as NodeEditorWindow;
w.wantsMouseMove = true;
w.graph = graph;
}
/// <summary> Repaint all open NodeEditorWindows. </summary>
public static void RepaintAll() {
NodeEditorWindow[] windows = Resources.FindObjectsOfTypeAll<NodeEditorWindow>();