From 46076527f850c10b7074558787299e015e7abc6b Mon Sep 17 00:00:00 2001 From: RomanZanevski <92728725+RomanZanevski@users.noreply.github.com> Date: Mon, 25 Apr 2022 16:24:08 +0200 Subject: [PATCH] Fix OnRemoveConnection from calling side If we use the original: if (port != null && port.IsConnectedTo(this)) port.node.OnRemoveConnection(port); we going to have always wrong condition, about "IsConnectedTo(this)" and port.node.OnRemoveConnection(port) just won't be called, cause we already have disconnected ports. So we need to do it exactly at the moment of disconnection. --- Scripts/NodePort.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Scripts/NodePort.cs b/Scripts/NodePort.cs index 9fa465e..6bcc638 100644 --- a/Scripts/NodePort.cs +++ b/Scripts/NodePort.cs @@ -296,12 +296,13 @@ namespace XNode { for (int i = 0; i < port.connections.Count; i++) { if (port.connections[i].Port == this) { port.connections.RemoveAt(i); + // Trigger OnRemoveConnection from this side port + port.node.OnRemoveConnection(port); } } } // Trigger OnRemoveConnection node.OnRemoveConnection(this); - if (port != null && port.IsConnectedTo(this)) port.node.OnRemoveConnection(port); } /// Disconnect this port from another port @@ -413,4 +414,4 @@ namespace XNode { } } } -} \ No newline at end of file +}