mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-21 01:36:03 +08:00
Destroy nodes on graph destruction #30
This commit is contained in:
parent
a78d7258ca
commit
69ee12169d
@ -38,10 +38,16 @@ namespace XNode {
|
|||||||
public void RemoveNode(Node node) {
|
public void RemoveNode(Node node) {
|
||||||
node.ClearConnections();
|
node.ClearConnections();
|
||||||
nodes.Remove(node);
|
nodes.Remove(node);
|
||||||
|
if (Application.isPlaying) Destroy(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Remove all nodes and connections from the graph </summary>
|
/// <summary> Remove all nodes and connections from the graph </summary>
|
||||||
public void Clear() {
|
public void Clear() {
|
||||||
|
if (Application.isPlaying) {
|
||||||
|
for (int i = 0; i < nodes.Count; i++) {
|
||||||
|
Destroy(nodes[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
nodes.Clear();
|
nodes.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,5 +73,10 @@ namespace XNode {
|
|||||||
|
|
||||||
return graph;
|
return graph;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnDestroy() {
|
||||||
|
// Remove all nodes prior to graph destruction
|
||||||
|
Clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user