diff --git a/Scripts/NodePort.cs b/Scripts/NodePort.cs
index c017534..b609066 100644
--- a/Scripts/NodePort.cs
+++ b/Scripts/NodePort.cs
@@ -9,8 +9,15 @@ namespace XNode {
public enum IO { Input, Output }
public int ConnectionCount { get { return connections.Count; } }
- /// Return the first connection
- public NodePort Connection { get { return connections.Count > 0 ? connections[0].Port : null; } }
+ /// Return the first non-null connection
+ public NodePort Connection {
+ get {
+ for (int i = 0; i < connections.Count; i++) {
+ if (connections[i] != null) return connections[i].Port;
+ }
+ return null;
+ }
+ }
public IO direction { get { return _direction; } }
public Node.ConnectionType connectionType { get { return _connectionType; } }