1
0
mirror of https://github.com/Siccity/xNode.git synced 2025-12-20 09:16:01 +08:00

Destroy nodes on graph destruction #30

This commit is contained in:
Thor Brigsted 2018-04-14 22:49:16 +02:00
parent a78d7258ca
commit 69ee12169d

View File

@ -38,10 +38,16 @@ namespace XNode {
public void RemoveNode(Node node) {
node.ClearConnections();
nodes.Remove(node);
if (Application.isPlaying) Destroy(node);
}
/// <summary> Remove all nodes and connections from the graph </summary>
public void Clear() {
if (Application.isPlaying) {
for (int i = 0; i < nodes.Count; i++) {
Destroy(nodes[i]);
}
}
nodes.Clear();
}
@ -67,5 +73,10 @@ namespace XNode {
return graph;
}
private void OnDestroy() {
// Remove all nodes prior to graph destruction
Clear();
}
}
}