Exemple #1
0
        /// <summary>
        /// Deletes this Node from curNodeCanvas
        /// </summary>
        public void Delete()
        {
            NodeEditor.curNodeCanvas.nodes.Remove(this);
            for (int outCnt = 0; outCnt < Outputs.Count; outCnt++)
            {
                NodeOutput output = Outputs [outCnt];
                while (output.connections.Count != 0)
                {
                    RemoveConnection(output.connections[0]);
                }
                DestroyImmediate(output, true);
            }
            for (int inCnt = 0; inCnt < Inputs.Count; inCnt++)
            {
                NodeInput input = Inputs [inCnt];
                if (input.connection != null)
                {
                    input.connection.connections.Remove(input);
                }
                DestroyImmediate(input, true);
            }

            NodeEditorCallbacks.IssueOnDeleteNode(this);

            DestroyImmediate(this, true);
        }
Exemple #2
0
 /// <summary>
 /// Deletes this Node from curNodeCanvas
 /// </summary>
 public void Delete()
 {
     if (!NodeEditor.curNodeCanvas.nodes.Contains(this))
     {
         throw new UnityException("The Node " + name + " does not exist on the Canvas " + NodeEditor.curNodeCanvas.name + "!");
     }
     NodeEditor.curNodeCanvas.nodes.Remove(this);
     for (int outCnt = 0; outCnt < Outputs.Count; outCnt++)
     {
         NodeOutput output = Outputs [outCnt];
         while (output.connections.Count != 0)
         {
             RemoveConnection(output.connections[0]);
         }
         DestroyImmediate(output, true);
     }
     for (int inCnt = 0; inCnt < Inputs.Count; inCnt++)
     {
         NodeInput input = Inputs [inCnt];
         if (input.connection != null)
         {
             input.connection.connections.Remove(input);
         }
         DestroyImmediate(input, true);
     }
     NodeEditorCallbacks.IssueOnDeleteNode(this);
     DestroyImmediate(this, true);
 }
Exemple #3
0
 /// <summary>
 /// Deletes this Node from curNodeCanvas and the save file
 /// </summary>
 public void Delete()
 {
     if (!NodeEditor.curNodeCanvas.nodes.Contains(this))
     {
         throw new UnityException("The Node " + name + " does not exist on the Canvas " + NodeEditor.curNodeCanvas.name + "!");
     }
     NodeEditorCallbacks.IssueOnDeleteNode(this);
     NodeEditor.curNodeCanvas.nodes.Remove(this);
     for (int outCnt = 0; outCnt < Outputs.Count; outCnt++)
     {
         NodeOutput output = Outputs [outCnt];
         while (output.connections.Count != 0)
         {
             output.connections[0].RemoveConnection();
         }
         DestroyImmediate(output, true);
     }
     for (int inCnt = 0; inCnt < Inputs.Count; inCnt++)
     {
         NodeInput input = Inputs [inCnt];
         if (input.connection != null)
         {
             input.connection.connections.Remove(input);
         }
         DestroyImmediate(input, true);
     }
     for (int knobCnt = 0; knobCnt < nodeKnobs.Count; knobCnt++)
     {             // Inputs/Outputs need specific treatment, unfortunately
         if (nodeKnobs[knobCnt] != null)
         {
             DestroyImmediate(nodeKnobs[knobCnt], true);
         }
     }
     DestroyImmediate(this, true);
 }
Exemple #4
0
        /// <summary>
        /// Deletes this Node from it's host canvas and the save file
        /// </summary>
        public void Delete(bool silent = false)
        {
            if (!canvas.nodes.Contains(this))
            {
                throw new UnityException("The Node " + name + " does not exist on the Canvas " + canvas.name + "!");
            }
            if (!silent)
            {
                NodeEditorCallbacks.IssueOnDeleteNode(this);
            }
            // DestroyImmediate(this, true);
            this.canvas.nodesForDelete.Add(this);
            canvas.nodes.Remove(this);

            for (int i = 0; i < connectionPorts.Count; i++)
            {
                connectionPorts[i].ClearConnections(silent);
                //DestroyImmediate(connectionPorts[i], true);
            }

            if (!silent)
            {
                canvas.Validate();
            }
        }
Exemple #5
0
 public void Delete()
 {
     if (!NodeEditor.curNodeCanvas.nodes.Contains(this))
     {
         throw new UnityException("The Node " + base.name + " does not exist on the Canvas " + NodeEditor.curNodeCanvas.name + "!");
     }
     NodeEditorCallbacks.IssueOnDeleteNode(this);
     NodeEditor.curNodeCanvas.nodes.Remove(this);
     for (int i = 0; i < Outputs.Count; i++)
     {
         NodeOutput nodeOutput = Outputs[i];
         while (nodeOutput.connections.Count != 0)
         {
             nodeOutput.connections[0].RemoveConnection();
         }
         UnityEngine.Object.DestroyImmediate(nodeOutput, true);
     }
     for (int j = 0; j < Inputs.Count; j++)
     {
         NodeInput nodeInput = Inputs[j];
         if ((UnityEngine.Object)nodeInput.connection != (UnityEngine.Object)null)
         {
             nodeInput.connection.connections.Remove(nodeInput);
         }
         UnityEngine.Object.DestroyImmediate(nodeInput, true);
     }
     for (int k = 0; k < nodeKnobs.Count; k++)
     {
         if ((UnityEngine.Object)nodeKnobs[k] != (UnityEngine.Object)null)
         {
             UnityEngine.Object.DestroyImmediate(nodeKnobs[k], true);
         }
     }
     UnityEngine.Object.DestroyImmediate(this, true);
 }
Exemple #6
0
        /// <summary>
        /// Deletes this Node from curNodeCanvas. Depends on that.
        /// </summary>
        public void Delete()
        {
            NodeEditor.curNodeCanvas.nodes.Remove(this);
            for (int outCnt = 0; outCnt < Outputs.Count; outCnt++)
            {
                NodeOutput output = Outputs [outCnt];
                for (int conCnt = 0; conCnt < output.connections.Count; conCnt++)
                {
                    output.connections [outCnt].connection = null;
                }
                DestroyImmediate(output, true);
            }
            for (int inCnt = 0; inCnt < Inputs.Count; inCnt++)
            {
                NodeInput input = Inputs [inCnt];
                if (input.connection != null)
                {
                    input.connection.connections.Remove(input);
                }
                DestroyImmediate(input, true);
            }

            DestroyImmediate(this, true);

        #if UNITY_EDITOR
            if (!String.IsNullOrEmpty(UnityEditor.AssetDatabase.GetAssetPath(NodeEditor.curNodeCanvas)))
            {
                UnityEditor.AssetDatabase.ImportAsset(UnityEditor.AssetDatabase.GetAssetPath(NodeEditor.curNodeCanvas));
            }
        #endif
            NodeEditorCallbacks.IssueOnDeleteNode(this);
        }
Exemple #7
0
        /// <summary>
        /// Deletes this Node from it's host canvas and the save file
        /// </summary>
        public void Delete(bool silent = false)
        {
            if (!canvas.nodes.Contains(this))
            {
                throw new UnityException("The Node " + name + " does not exist on the Canvas " + canvas.name + "!");
            }
            if (!silent)
            {
                NodeEditorCallbacks.IssueOnDeleteNode(this);
            }

#if UNITY_EDITOR
            if (!silent)
            {
                List <ConnectionPort> connectedPorts = new List <ConnectionPort>();
                foreach (ConnectionPort port in connectionPorts)
                {                 // 'Encode' connected ports in one list (double level cannot be serialized)
                    foreach (ConnectionPort conn in port.connections)
                    {
                        connectedPorts.Add(conn);
                    }
                    connectedPorts.Add(null);
                }
                Node deleteNode = this;
                UndoPro.UndoProManager.RecordOperation(
                    () => NodeEditorUndoActions.RemoveNode(deleteNode),
                    () => NodeEditorUndoActions.ReinstateNode(deleteNode, connectedPorts),
                    "Delete Node");
                // Make sure the deleted node is in the memory dump
                NodeEditorUndoActions.CompleteSOMemoryDump(canvas);
            }
#endif

            canvas.nodes.Remove(this);
            for (int i = 0; i < connectionPorts.Count; i++)
            {
                connectionPorts[i].ClearConnections(true);
            }

            if (!silent)
            {
                canvas.Validate();
            }
        }