Exemple #1
0
        ///Sets the target node of the connection
        public int SetTargetNode(Node newTarget, int index = -1)
        {
            if (targetNode == newTarget)
            {
                return(-1);
            }

            if (graph != null)
            {
                graph.RecordUndo("Set Target");
            }

            //relink
            if (targetNode != null && targetNode.inConnections.Contains(this))
            {
                var i = targetNode.inConnections.IndexOf(this);
                targetNode.OnParentDisconnected(i);
                targetNode.inConnections.Remove(this);
            }

            index = index == -1 ? newTarget.inConnections.Count : index;
            newTarget.inConnections.Insert(index, this);
            newTarget.OnParentConnected(index);
            targetNode = newTarget;

#if UNITY_EDITOR
            if (sourceNode != null && targetNode != null)
            {
                targetNode.TrySortConnectionsByPositionX();
            }
#endif

            return(index);
        }
Exemple #2
0
        ///Relinks the target node of the connection
        public void SetTarget(Node newTarget, bool isRelink = true, int index = -1)
        {
            if (targetNode == newTarget)
            {
                return;
            }

            if (graph != null)
            {
                graph.RecordUndo("Set Target");
            }

            if (isRelink)
            {
                var i = targetNode.inConnections.IndexOf(this);
                targetNode.OnParentDisconnected(i);
                newTarget.OnParentConnected(i);
                targetNode.inConnections.Remove(this);
            }

            index = index == -1? newTarget.inConnections.Count : index;
            newTarget.inConnections.Insert(index, this);
            targetNode = newTarget;

                        #if UNITY_EDITOR
            targetNode.TrySortConnectionsByPositionX();
                        #endif
        }
Exemple #3
0
        ///<summary>Sets the target node of the connection</summary>
        public int SetTargetNode(Node newTarget, int index = -1)
        {
            if (targetNode == newTarget)
            {
                return(-1);
            }

            UndoUtility.RecordObject(graph, "Set Target");

            //relink
            if (targetNode != null && targetNode.inConnections.Contains(this))
            {
                var i = targetNode.inConnections.IndexOf(this);
                targetNode.OnParentDisconnected(i);
                targetNode.inConnections.Remove(this);
            }

            index = index == -1 ? newTarget.inConnections.Count : index;
            newTarget.inConnections.Insert(index, this);
            newTarget.OnParentConnected(index);
            targetNode = newTarget;

#if UNITY_EDITOR
            if (sourceNode != null && targetNode != null)
            {
                targetNode.TrySortConnectionsByPositionX();
            }
#endif

            OnValidate(sourceNode != null ? sourceNode.outConnections.IndexOf(this) : -1, index);
            UndoUtility.SetDirty(graph);
            return(index);
        }
Exemple #4
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);
        }
Exemple #5
0
        ///Relinks the target node of the connection
        public void SetTarget(Node newTarget, bool isRelink = true)
        {
                        #if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                UnityEditor.Undo.RecordObject(graph, "Set Target");
            }
                        #endif

            if (isRelink)
            {
                var i = targetNode.inConnections.IndexOf(this);
                targetNode.OnParentDisconnected(i);
                newTarget.OnParentConnected(i);

                targetNode.inConnections.Remove(this);
            }
            newTarget.inConnections.Add(this);

            targetNode = newTarget;
        }
        ///Relinks the target node of the connection
        public void SetTarget(Node newTarget, bool isRelink = true)
        {
            if (targetNode == newTarget)
            {
                return;
            }

            if (graph != null)
            {
                graph.RecordUndo("Set Target");
            }

            if (isRelink)
            {
                var i = targetNode.inConnections.IndexOf(this);
                targetNode.OnParentDisconnected(i);
                newTarget.OnParentConnected(i);
                targetNode.inConnections.Remove(this);
            }
            newTarget.inConnections.Add(this);
            targetNode = newTarget;
        }
Exemple #7
0
		///Relinks the target node of the connection
		public void SetTarget(Node newTarget, bool isRelink = true){
			
			#if UNITY_EDITOR
			if (!Application.isPlaying){
				UnityEditor.Undo.RecordObject(graph, "Set Target");
			}
			#endif

			if (isRelink){
				var i = targetNode.inConnections.IndexOf(this);
				targetNode.OnParentDisconnected(i);
				newTarget.OnParentConnected(i);

				targetNode.inConnections.Remove(this);
			}
			newTarget.inConnections.Add(this);

			targetNode = newTarget;
		}