///Editor. Connection Relink has ended. Handle effect
 virtual public void OnActiveRelinkEnd(Connection connection)
 {
     for (var i = 0; i < graph.allNodes.Count; i++)
     {
         var otherNode = graph.allNodes[i];
         if (otherNode != connection.targetNode && otherNode != connection.sourceNode && otherNode.rect.Contains(Event.current.mousePosition))
         {
             if (connection.relinkState == Connection.RelinkState.Target)
             {
                 if (Node.IsNewConnectionAllowed(connection.sourceNode, otherNode, connection))
                 {
                     connection.SetTarget(otherNode);
                 }
             }
             if (connection.relinkState == Connection.RelinkState.Source)
             {
                 if (Node.IsNewConnectionAllowed(otherNode, connection.targetNode, connection))
                 {
                     connection.SetSource(otherNode);
                 }
             }
             return;
         }
     }
 }
Пример #2
0
        ///Connect two nodes together to a specific port index of the source node
        public Connection ConnectNodes(Node sourceNode, Node targetNode, int indexToInsert)
        {
            if (targetNode.IsNewConnectionAllowed(sourceNode) == false)
            {
                return(null);
            }

            RecordUndo("New Connection");

            var newConnection = Connection.Create(sourceNode, targetNode, indexToInsert);

            sourceNode.OnChildConnected(indexToInsert);
            targetNode.OnParentConnected(targetNode.inConnections.IndexOf(newConnection));

            UpdateNodeIDs(false);
            return(newConnection);
        }