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:
parent
a78d7258ca
commit
69ee12169d
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user