diff --git a/Scripts/Node.cs b/Scripts/Node.cs
index 488971a..e22b78f 100644
--- a/Scripts/Node.cs
+++ b/Scripts/Node.cs
@@ -47,7 +47,7 @@ namespace XNode {
foreach (NodePort port in Ports) port.VerifyConnections();
}
- #region Instance Ports
+#region Instance Ports
/// Returns input port at index
public NodePort AddInstanceInput(Type type, string fieldName = null) {
return AddInstancePort(type, NodePort.IO.Input, fieldName);
@@ -72,16 +72,21 @@ namespace XNode {
return port;
}
- public bool RemoveInstancePort(string fieldName) {
- NodePort port = GetPort(fieldName);
- if (port == null || port.IsStatic) return false;
- port.ClearConnections();
- ports.Remove(fieldName);
- return true;
+ /// Remove an instance port from the node
+ public void RemoveInstancePort(string fieldName) {
+ RemoveInstancePort(GetPort(fieldName));
}
- #endregion
- #region Ports
+ /// Remove an instance port from the node
+ public void RemoveInstancePort(NodePort port) {
+ if (port == null) throw new ArgumentNullException("port");
+ else if (port.IsStatic) throw new ArgumentException("cannot remove static port");
+ port.ClearConnections();
+ ports.Remove(port.fieldName);
+ }
+#endregion
+
+#region Ports
/// Returns output port which matches fieldName
public NodePort GetOutputPort(string fieldName) {
NodePort port = GetPort(fieldName);
@@ -105,9 +110,9 @@ namespace XNode {
public bool HasPort(string fieldName) {
return ports.ContainsKey(fieldName);
}
- #endregion
+#endregion
- #region Inputs/Outputs
+#region Inputs/Outputs
/// Return input value for a specified port. Returns fallback value if no ports are connected
/// Field name of requested input port
/// If no ports are connected, this value will be returned
@@ -132,7 +137,7 @@ namespace XNode {
Debug.LogWarning("No GetValue(NodePort port) override defined for " + GetType());
return null;
}
- #endregion
+#endregion
/// Called after a connection between two s is created
/// Output Input