mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-21 01:36:03 +08:00
[FIX] added reroute ports to SwapConnections method in NodePort class
This commit is contained in:
parent
8046e6e0bf
commit
c3df910203
@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@ -337,16 +337,33 @@ namespace XNode {
|
|||||||
int aConnectionCount = connections.Count;
|
int aConnectionCount = connections.Count;
|
||||||
int bConnectionCount = targetPort.connections.Count;
|
int bConnectionCount = targetPort.connections.Count;
|
||||||
|
|
||||||
|
List<List<Vector2>> aReroutePoints = new List<List<Vector2>>();
|
||||||
|
List<List<Vector2>> bReroutePoints = new List<List<Vector2>>();
|
||||||
|
|
||||||
List<NodePort> portConnections = new List<NodePort>();
|
List<NodePort> portConnections = new List<NodePort>();
|
||||||
List<NodePort> targetPortConnections = new List<NodePort>();
|
List<NodePort> targetPortConnections = new List<NodePort>();
|
||||||
|
|
||||||
// Cache port connections
|
// Cache port connections
|
||||||
for (int i = 0; i < aConnectionCount; i++)
|
for (int i = 0; i < aConnectionCount; i++)
|
||||||
|
{
|
||||||
portConnections.Add(connections[i].Port);
|
portConnections.Add(connections[i].Port);
|
||||||
|
aReroutePoints.Add(new List<Vector2>());
|
||||||
|
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++)
|
for (int i = 0; i < bConnectionCount; i++)
|
||||||
|
{
|
||||||
targetPortConnections.Add(targetPort.connections[i].Port);
|
targetPortConnections.Add(targetPort.connections[i].Port);
|
||||||
|
bReroutePoints.Add(new List<Vector2>());
|
||||||
|
for (int e = 0; e < targetPort.connections[i].reroutePoints.Count; e++)
|
||||||
|
{
|
||||||
|
bReroutePoints[i].Add(targetPort.connections[i].reroutePoints[e]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ClearConnections();
|
ClearConnections();
|
||||||
targetPort.ClearConnections();
|
targetPort.ClearConnections();
|
||||||
@ -359,6 +376,15 @@ namespace XNode {
|
|||||||
for (int i = 0; i < targetPortConnections.Count; i++)
|
for (int i = 0; i < targetPortConnections.Count; i++)
|
||||||
Connect(targetPortConnections[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];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Copy all connections pointing to a node and add them to this one </summary>
|
/// <summary> Copy all connections pointing to a node and add them to this one </summary>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user