Exemple #1
0
        public static Node Create(GraphBase targetGraph, System.Type nodeType, Rect rect)
        {
            if (targetGraph == null)
            {
                Debug.LogError("Can't Create a Node without providing a Target Graph");
                return(null);
            }

            var newNode = (Node)System.Activator.CreateInstance(nodeType);

            newNode.rect      = rect;
            newNode.graphBase = targetGraph;
            newNode.OnValidate(targetGraph);
            return(newNode);
        }
Exemple #2
0
        //Construct
        public GraphSerializationData(GraphBase graph)
        {
            //connections are serialized seperately and not part of their parent node
            this.nodes = graph.allNodes;
            var structConnections = new List <Connection>();

            for (var i = 0; i < nodes.Count; i++)
            {
                for (var j = 0; j < nodes[i].outConnections.Count; j++)
                {
                    structConnections.Add(nodes[i].outConnections[j]);
                }
            }

            this.connections = structConnections;
            graph.OnSerialize(this);
        }
Exemple #3
0
        ///MUST reconstruct before using the data
        public void Reconstruct(GraphBase graph)
        {
            //check serialization versions here in the future if needed

            //re-link connections for deserialization
            for (var i = 0; i < this.connections.Count; i++)
            {
                connections[i].sourceNode.outConnections.Add(connections[i]);
                connections[i].targetNode.inConnections.Add(connections[i]);
            }

            //re-set the node's owner
            for (var i = 0; i < this.nodes.Count; i++)
            {
                nodes[i].graphBase = graph;
            }

            graph.OnDeserialize(this);
        }
Exemple #4
0
 // be critical, this is will init inputPorts and outputPorts
 public override void OnValidate(GraphBase flowGraph)
 {
     GatherPorts();
 }
Exemple #5
0
 // call when create node
 virtual public void OnValidate(GraphBase assignedGraph)
 {
 }