-
-
Notifications
You must be signed in to change notification settings - Fork 597
NodeGraph.Copy
Thor Brigsted edited this page Apr 7, 2018
·
1 revision
Create a new deep copy of this graph
public NodeGraph Copy();
Attempting to copy a NodeGraph using Object.Instantiate(myGraph);
will only return a shallow copy.
To perform a full deep copy of the graph, use graph.Copy();
using UnityEngine;
public class GraphCopy : MonoBevaviour {
public MyNodeGraph prefab;
void Start() {
// Create a new deep copy of the node graph
MyNodeGraph copy = prefab.Copy() as MyNodeGraph;
// Check if a node in the new copy points to the prefab
if (copy.nodes[0].graph == prefab) Debug.LogError("Referencing prefab");
else Debug.Log("Referencing new copy");
}
}