mirror of
https://github.com/Siccity/xNode.git
synced 2026-02-10 00:58:44 +08:00
Fix potential error when copying a NodeGraph with null nodes
This commit is contained in:
parent
1885d453a4
commit
588fc0d80a
@ -51,6 +51,7 @@ namespace XNode {
|
|||||||
NodeGraph graph = Instantiate(this);
|
NodeGraph graph = Instantiate(this);
|
||||||
// Instantiate all nodes inside the graph
|
// Instantiate all nodes inside the graph
|
||||||
for (int i = 0; i < nodes.Count; i++) {
|
for (int i = 0; i < nodes.Count; i++) {
|
||||||
|
if (nodes[i] == null) continue;
|
||||||
Node node = Instantiate(nodes[i]) as Node;
|
Node node = Instantiate(nodes[i]) as Node;
|
||||||
node.graph = graph;
|
node.graph = graph;
|
||||||
graph.nodes[i] = node;
|
graph.nodes[i] = node;
|
||||||
@ -58,6 +59,7 @@ namespace XNode {
|
|||||||
|
|
||||||
// Redirect all connections
|
// Redirect all connections
|
||||||
for (int i = 0; i < graph.nodes.Count; i++) {
|
for (int i = 0; i < graph.nodes.Count; i++) {
|
||||||
|
if (graph.nodes[i] == null) continue;
|
||||||
foreach (NodePort port in graph.nodes[i].Ports) {
|
foreach (NodePort port in graph.nodes[i].Ports) {
|
||||||
port.Redirect(nodes, graph.nodes);
|
port.Redirect(nodes, graph.nodes);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user