diff --git a/Scripts/Editor/NodeEditorGUI.cs b/Scripts/Editor/NodeEditorGUI.cs index e1f8e42..a5ee942 100644 --- a/Scripts/Editor/NodeEditorGUI.cs +++ b/Scripts/Editor/NodeEditorGUI.cs @@ -116,7 +116,7 @@ public partial class NodeEditorWindow { public void DrawConnections() { foreach (Node node in graph.nodes) { //If a null node is found, return. This can happen if the nodes associated script is deleted. It is currently not possible in Unity to delete a null asset. - if (node == null) return; + if (node == null) continue; for (int i = 0; i < node.OutputCount; i++) { NodePort output = node.outputs[i]; @@ -126,8 +126,9 @@ public partial class NodeEditorWindow { for (int k = 0; k < output.ConnectionCount; k++) { NodePort input = output.GetConnection(k); - if (input == null) return; //If a script has been updated and the port doesn't exist, it is removed and null is returned. If this happens, return. - if (!_portConnectionPoints.ContainsKey(input)) return; + if (input == null) continue; //If a script has been updated and the port doesn't exist, it is removed and null is returned. If this happens, return. + if (!input.IsConnectedTo(output)) input.Connect(output); + if (!_portConnectionPoints.ContainsKey(input)) continue; Vector2 to = _portConnectionPoints[input].center; DrawConnection(from, to, NodeEditorPreferences.GetTypeColor(output.type)); } diff --git a/Scripts/NodePort.cs b/Scripts/NodePort.cs index 5fcd99d..4a55fc4 100644 --- a/Scripts/NodePort.cs +++ b/Scripts/NodePort.cs @@ -145,7 +145,7 @@ public class NodePort { if (direction == port.direction) { Debug.LogWarning("Cannot connect two " + (direction == IO.Input ? "input" : "output") + " connections"); return; } connections.Add(new PortConnection(port)); if (port.connections == null) port.connections = new List(); - port.connections.Add(new PortConnection(this)); + if (!port.IsConnectedTo(this)) port.connections.Add(new PortConnection(this)); node.OnCreateConnection(this, port); port.node.OnCreateConnection(this, port); }