Ejemplo n.º 1
0
        /// <summary> Add a node to the graph by type </summary>
        public virtual INode AddNode(Type type)
        {
            MonoNode.graphHotfix = this;
            MonoNode node = gameObject.AddComponent(type) as MonoNode;

            node.OnEnable();
            node.graph = this;
            var nodesList = new List <MonoNode>(nodes);

            nodesList.Add(node);
            nodes = nodesList.ToArray();
            return(node);
        }
Ejemplo n.º 2
0
        /// <summary> Creates a copy of the original node in the graph </summary>
        public virtual INode CopyNode(INode original)
        {
            MonoNode castedNode = original as MonoNode;

            if (castedNode == null)
            {
                throw new ArgumentException("NodeGraph can only copy nodes scriptable objects");
            }

            MonoNode.graphHotfix = this;
            MonoNode node = gameObject.AddComponent(original.GetType()) as MonoNode;

            node.graph = this;
            node.ClearConnections();
            var nodesList = new List <MonoNode>(nodes);

            nodesList.Add(node);
            nodes = nodesList.ToArray();
            return(node);
        }