diff --git a/Scripts/NodePort.cs b/Scripts/NodePort.cs index 1fbc62f..82fd9b0 100644 --- a/Scripts/NodePort.cs +++ b/Scripts/NodePort.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Reflection; using UnityEngine; @@ -19,7 +19,7 @@ namespace XNode { } } - public IO direction { + public IO direction { get { return _direction; } internal set { _direction = value; } } @@ -341,16 +341,33 @@ namespace XNode { int aConnectionCount = connections.Count; int bConnectionCount = targetPort.connections.Count; + List> aReroutePoints = new List>(); + List> bReroutePoints = new List>(); + List portConnections = new List(); List targetPortConnections = new List(); // Cache port connections for (int i = 0; i < aConnectionCount; i++) + { portConnections.Add(connections[i].Port); + aReroutePoints.Add(new List()); + for (int e = 0; e < connections[i].reroutePoints.Count; e++) + { + aReroutePoints[i].Add(connections[i].reroutePoints[e]); + } + } - // Cache target port connections + // Cache target port connections and reroute points for (int i = 0; i < bConnectionCount; i++) + { targetPortConnections.Add(targetPort.connections[i].Port); + bReroutePoints.Add(new List()); + for (int e = 0; e < targetPort.connections[i].reroutePoints.Count; e++) + { + bReroutePoints[i].Add(targetPort.connections[i].reroutePoints[e]); + } + } ClearConnections(); targetPort.ClearConnections(); @@ -363,6 +380,15 @@ namespace XNode { for (int i = 0; i < targetPortConnections.Count; i++) Connect(targetPortConnections[i]); + // Add the reroute poins + for (int i = 0; i < aConnectionCount; i++) + { + targetPort.connections[i].reroutePoints = aReroutePoints[i]; + } + for (int i = 0; i < bConnectionCount; i++) + { + connections[i].reroutePoints = bReroutePoints[i]; + } } /// Copy all connections pointing to a node and add them to this one