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:
parent
af0523db2d
commit
71c395371e
@ -70,6 +70,17 @@ namespace XNodeEditor {
|
|||||||
if (graphEditor != null && NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
|
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>
|
/// <summary> Create editor window </summary>
|
||||||
public static NodeEditorWindow Init() {
|
public static NodeEditorWindow Init() {
|
||||||
NodeEditorWindow w = CreateInstance<NodeEditorWindow>();
|
NodeEditorWindow w = CreateInstance<NodeEditorWindow>();
|
||||||
@ -147,14 +158,21 @@ namespace XNodeEditor {
|
|||||||
public static bool OnOpen(int instanceID, int line) {
|
public static bool OnOpen(int instanceID, int line) {
|
||||||
XNode.NodeGraph nodeGraph = EditorUtility.InstanceIDToObject(instanceID) as XNode.NodeGraph;
|
XNode.NodeGraph nodeGraph = EditorUtility.InstanceIDToObject(instanceID) as XNode.NodeGraph;
|
||||||
if (nodeGraph != null) {
|
if (nodeGraph != null) {
|
||||||
NodeEditorWindow w = GetWindow(typeof(NodeEditorWindow), false, "xNode", true) as NodeEditorWindow;
|
Open(nodeGraph);
|
||||||
w.wantsMouseMove = true;
|
|
||||||
w.graph = nodeGraph;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
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>
|
/// <summary> Repaint all open NodeEditorWindows. </summary>
|
||||||
public static void RepaintAll() {
|
public static void RepaintAll() {
|
||||||
NodeEditorWindow[] windows = Resources.FindObjectsOfTypeAll<NodeEditorWindow>();
|
NodeEditorWindow[] windows = Resources.FindObjectsOfTypeAll<NodeEditorWindow>();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user