From c3df91020321c547e826e6a407555f36d9537993 Mon Sep 17 00:00:00 2001 From: FDT Date: Sun, 10 May 2020 16:17:19 +0200 Subject: [PATCH] [FIX] added reroute ports to SwapConnections method in NodePort class --- Scripts/NodePort.cs | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/Scripts/NodePort.cs b/Scripts/NodePort.cs index b2f1ad1..2aa3496 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; } } @@ -337,16 +337,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(); @@ -359,6 +376,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 @@ -415,4 +441,4 @@ namespace XNode { } } } -} \ No newline at end of file +}