Skip to content

Commit ba0468c

Browse files
committed
Node inspector object is now serialized for an editor session
1 parent 4b14c15 commit ba0468c

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

Assets/com.alelievr.NodeGraphProcessor/Editor/Views/BaseGraphView.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,17 @@ public class BaseGraphView : GraphView, IDisposable
114114
/// <summary>
115115
/// Object to handle nodes that shows their UI in the inspector.
116116
/// </summary>
117-
[NonSerialized]
118-
protected NodeInspectorObject nodeInspector;
117+
[SerializeField]
118+
protected NodeInspectorObject nodeInspector
119+
{
120+
get
121+
{
122+
123+
if (graph.nodeInspectorReference == null)
124+
graph.nodeInspectorReference = CreateNodeInspectorObject();
125+
return graph.nodeInspectorReference as NodeInspectorObject;
126+
}
127+
}
119128

120129
/// <summary>
121130
/// Workaround object for creating exposed parameter property fields.
@@ -150,9 +159,6 @@ public BaseGraphView(EditorWindow window)
150159
createNodeMenu = ScriptableObject.CreateInstance< CreateNodeMenuWindow >();
151160
createNodeMenu.Initialize(this, window);
152161

153-
if (nodeInspector == null)
154-
nodeInspector = CreateNodeInspectorObject();
155-
156162
this.StretchToParentSize();
157163
}
158164

Assets/com.alelievr.NodeGraphProcessor/Runtime/Graph/BaseGraph.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ public class BaseGraph : ScriptableObject, ISerializationCallbackReceiver
127127
[NonSerialized]
128128
Scene linkedScene;
129129

130+
// Trick to keep the node inspector alive during the editor session
131+
[SerializeField]
132+
internal UnityEngine.Object nodeInspectorReference;
133+
130134
//graph visual properties
131135
public Vector3 position = Vector3.zero;
132136
public Vector3 scale = Vector3.one;

Assets/com.alelievr.NodeGraphProcessor/Runtime/Processing/ProcessGraphProcessor.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,14 @@ public override void UpdateComputeOrder()
2828
}
2929

3030
/// <summary>
31-
/// Schedule the graph into the job system
31+
/// Process all the nodes following the compute order.
3232
/// </summary>
3333
public override void Run()
3434
{
3535
int count = processList.Count;
3636

3737
for (int i = 0; i < count; i++)
38-
{
3938
processList[i].OnProcess();
40-
}
41-
42-
JobHandle.ScheduleBatchedJobs();
4339
}
4440
}
4541
}

0 commit comments

Comments
 (0)