예제 #1
0
        /// <summary>
        /// Applies a connection between between this port and the specified port.
        /// 'CanApplyConnection' has to be checked before to avoid interferences!
        /// </summary>
        public void ApplyConnection(ConnectionPort port, bool silent = false)
        {
            if (port == null)
            {
                return;
            }

            if (maxConnectionCount == ConnectionCount.Single && connections.Count > 0)
            {             // Respect maximum connection count on this port
                RemoveConnection(connections[0], silent);
                connections.Clear();
            }
            connections.Add(port);

            if (port.maxConnectionCount == ConnectionCount.Single && port.connections.Count > 0)
            {             // Respect maximum connection count on the other port
                port.RemoveConnection(port.connections[0], silent);
                port.connections.Clear();
            }
            port.connections.Add(this);

            if (!silent)
            {             // Callbacks
                port.body.OnAddConnection(port, this);
                body.OnAddConnection(this, port);
                NodeEditorCallbacks.IssueOnAddConnection(this, port);
                NodeEditor.curNodeCanvas.OnNodeChange(direction == Direction.In? port.body : body);
            }
        }
예제 #2
0
        /// <summary>
        /// Applies a connection between the passed NodeOutput and this NodeInput. 'CanApplyConnection' has to be checked before to avoid interferences!
        /// </summary>
        public void ApplyConnection(NodeOutput output)
        {
            if (output == null)
            {
                return;
            }

            if (connection != null)
            {
                NodeEditorCallbacks.IssueOnRemoveConnection(this);
                connection.connections.Remove(this);
            }
            connection = output;
            output.connections.Add(this);

            if (!output.body.calculated)
            {
                NodeEditor.RecalculateFrom(output.body);
            }
            else
            {
                NodeEditor.RecalculateFrom(body);
            }

            output.body.OnAddOutputConnection(output);
            body.OnAddInputConnection(this);
            NodeEditorCallbacks.IssueOnAddConnection(this);
        }
예제 #3
0
        /// <summary>
        /// Applies a connection between between this port and the specified port.
        /// 'CanApplyConnection' has to be checked before to avoid interferences!
        /// </summary>
        public void ApplyConnection(ConnectionPort port, bool silent = false)
        {
            if (port == null)
            {
                return;
            }

            Undo.RecordObjects(new [] { this, port }, "NodeEditor_连接保存");
            if (maxConnectionCount == ConnectionCount.Single && connections.Count > 0)
            {
                // Respect maximum connection count on this port
                RemoveConnection(connections[0], silent);
                connections.Clear();
            }

            connections.Add(port);

            if (port.maxConnectionCount == ConnectionCount.Single && port.connections.Count > 0)
            {
                // Respect maximum connection count on the other port
                port.RemoveConnection(port.connections[0], silent);
                port.connections.Clear();
            }

            port.connections.Add(this);

            if (!silent)
            {
                // Callbacks
                port.body.OnAddConnection(port, this);
                body.OnAddConnection(this, port);
                NodeEditorCallbacks.IssueOnAddConnection(this, port);
            }
        }
예제 #4
0
        /// <summary>
        /// Applies a connection between output and input. 'CanApplyConnection' has to be checked before
        /// </summary>
        public static void ApplyConnection(NodeOutput output, NodeInput input)
        {
            if (input != null && output != null)
            {
                if (input.connection != null)
                {
                    input.connection.connections.Remove(input);
                }
                input.connection = output;
                output.connections.Add(input);

                NodeEditor.RecalculateFrom(input.body);

                NodeEditorCallbacks.IssueOnAddConnection(input);
            }
        }
예제 #5
0
        /// <summary>
        /// Applies a connection between the passed NodeOutput and this NodeInput. 'CanApplyConnection' has to be checked before to avoid interferences!
        /// </summary>
        public void ApplyConnection(NodeOutput output)
        {
            if (output == null)
            {
                return;
            }

            if (connection != null)
            {
                NodeEditorCallbacks.IssueOnRemoveConnection(this);
                connection.connections.Remove(this);
            }
            connection = output;
            output.connections.Add(this);
            output.body.OnAddOutputConnection(output);
            body.OnAddInputConnection(this);
            NodeEditorCallbacks.IssueOnAddConnection(this);

            NodeEditor.curNodeCanvas.OnNodeChange(body);
        }
예제 #6
0
        /// <summary>
        /// Applies a connection between between this port and the specified port.
        /// 'CanApplyConnection' has to be checked before to avoid interferences!
        /// </summary>
        public void ApplyConnection(ConnectionPort port, bool silent = false)
        {
            if (port == null)
            {
                return;
            }

            if (maxConnectionCount == ConnectionCount.Single && connections.Count > 0)
            {             // Respect maximum connection count on this port
                RemoveConnection(connections[0], silent);
                connections.Clear();
            }
            connections.Add(port);

            if (port.maxConnectionCount == ConnectionCount.Single && port.connections.Count > 0)
            {             // Respect maximum connection count on the other port
                port.RemoveConnection(port.connections[0], silent);
                port.connections.Clear();
            }
            port.connections.Add(this);

#if UNITY_EDITOR
            if (!silent)
            {             // Create Undo record
                          // Important: Copy variables used within anonymous functions within same level (this if block) for correct serialization!
                ConnectionPort port1 = this, port2 = port;
                UndoPro.UndoProManager.RecordOperation(
                    () => NodeEditorUndoActions.CreateConnection(port1, port2),
                    () => NodeEditorUndoActions.DeleteConnection(port1, port2),
                    "Create Connection");
            }
#endif

            if (!silent)
            {             // Callbacks
                port.body.OnAddConnection(port, this);
                body.OnAddConnection(this, port);
                NodeEditorCallbacks.IssueOnAddConnection(this, port);
                body.canvas.OnNodeChange(direction == Direction.In? port.body : body);
            }
        }
 public void ApplyConnection(NodeOutput output)
 {
     if (!((UnityEngine.Object)output == (UnityEngine.Object)null))
     {
         if ((UnityEngine.Object)connection != (UnityEngine.Object)null)
         {
             NodeEditorCallbacks.IssueOnRemoveConnection(this);
             connection.connections.Remove(this);
         }
         connection = output;
         output.connections.Add(this);
         if (!output.body.calculated)
         {
             NodeEditor.RecalculateFrom(output.body);
         }
         else
         {
             NodeEditor.RecalculateFrom(body);
         }
         output.body.OnAddOutputConnection(output);
         body.OnAddInputConnection(this);
         NodeEditorCallbacks.IssueOnAddConnection(this);
     }
 }