Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Scripts/Editor/NodeEditorBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,14 @@ public static T GetEditor(K target, NodeEditorWindow window) {
editor.target = target;
editor.serializedObject = new SerializedObject(target);
editor.window = window;

// OnCreate is obsolete - use OnEnable instead
#pragma warning disable 0618
editor.OnCreate();
#pragma warning restore 0618

editors.Add(target, editor);
editor.OnEnable();
}
if (editor.target == null) editor.target = target;
if (editor.window != window) editor.window = window;
Expand Down Expand Up @@ -81,9 +87,18 @@ private static void CacheCustomEditors() {
}
}

/// <summary> Clears stored editors. Called when a new graph opens. Ensures that NodeEditor.OnEnable is called as expected. </summary>
public static void ClearCachedEditors() {
editors = new Dictionary<K, T>();
}

/// <summary> Called on creation, after references have been set </summary>
[Obsolete("OnCreate() is deprecated, please use OnEnable() instead.")]
public virtual void OnCreate() { }

/// <summary> Called when a graph containing the node is opened </summary>
public virtual void OnEnable() { }

public interface INodeEditorAttrib {
Type GetInspectedType();
}
Expand Down
2 changes: 2 additions & 0 deletions Scripts/Editor/NodeEditorWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ private void OnDisable() {
}

private void OnEnable() {
NodeEditor.ClearCachedEditors();
// Reload portConnectionPoints if there are any
int length = _references.Length;
if (length == _rects.Length) {
Expand Down Expand Up @@ -193,6 +194,7 @@ public static NodeEditorWindow Open(XNode.NodeGraph graph) {
NodeEditorWindow w = GetWindow(typeof(NodeEditorWindow), false, "xNode", true) as NodeEditorWindow;
w.wantsMouseMove = true;
w.graph = graph;
NodeEditor.ClearCachedEditors();
return w;
}

Expand Down