/// <summary> Creates a copy of the original node in the graph </summary>
        public virtual Node CopyNode(Node original)
        {
            Node.graphHotfix = this;
            Node node = ScriptableObject.Instantiate(original);

            node.graph = this;
            node.ClearConnections();
            nodes.Add(node);
            return(node);
        }
Ejemplo n.º 2
0
        /// <summary> Safely remove a node and all its connections </summary>
        /// <param name="node"> The node to remove </param>
        public virtual void RemoveNode(Node node)
        {
            node.ClearConnections();
            nodes.Remove(node);
#if !NON_SCRIPTABLE
            if (Application.isPlaying)
            {
                Destroy(node);
            }
#endif
        }
Ejemplo n.º 3
0
        /// <summary> Safely remove a node and all its connections </summary>
        /// <param name="node"></param>
        public void RemoveNode(Node node)
        {
            node.ClearConnections();
#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                DestroyImmediate(node, true);
                UnityEditor.AssetDatabase.SaveAssets();
            }
#endif
            nodes.Remove(node);
        }
Ejemplo n.º 4
0
        /// <summary> Safely remove a node and all its connections </summary>
        /// <param name="node"></param>
        public void RemoveNode(Node node)
        {
#if UNITY_EDITOR
            UnityEditor.Undo.RecordObject(this, "Remove Node");
#endif
            node.ClearConnections();
            nodes.Remove(node);
#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                DestroyImmediate(node, true);
            }
            UnityEditor.EditorUtility.SetDirty(this);
#endif
        }
Ejemplo n.º 5
0
        /// <summary> Creates a copy of the original node in the graph </summary>
        public virtual Node CopyNode(Node original)
        {
            Node node = ScriptableObject.Instantiate(original);

            node.ClearConnections();
#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                UnityEditor.AssetDatabase.AddObjectToAsset(node, this);
                UnityEditor.AssetDatabase.SaveAssets();
            }
#endif
            nodes.Add(node);
            node.graph = this;
            return(node);
        }
        /// <summary> Creates a copy of the original node in the graph </summary>
        public virtual INode CopyNode(INode original)
        {
            Node castedNode = original as Node;

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

            Node.graphHotfix = this;
            Node node = ScriptableObject.Instantiate(castedNode);

            node.graph = this;
            node.ClearConnections();
            nodes.Add(node);
            return(node);
        }
Ejemplo n.º 7
0
        /// <summary> Creates a copy of the original node in the graph </summary>
        public virtual Node CopyNode(Node original)
        {
#if UNITY_EDITOR
            UnityEditor.Undo.RecordObject(this, "Copy Node");
#endif
            Node node = ScriptableObject.Instantiate(original);
            node.ClearConnections();
            nodes.Add(node);
            node.graph = this;
#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                UnityEditor.AssetDatabase.AddObjectToAsset(node, this);
                node.name = UnityEditor.ObjectNames.NicifyVariableName(node.name);
            }
            UnityEditor.EditorUtility.SetDirty(this);
#endif
            return(node);
        }
Ejemplo n.º 8
0
 /// <summary> Safely remove a node and all its connections </summary>
 /// <param name="node"></param>
 public void RemoveNode(Node node)
 {
     node.ClearConnections();
     nodes.Remove(node);
 }