diff --git a/Scripts/Editor/NodeEditorGUILayout.cs b/Scripts/Editor/NodeEditorGUILayout.cs
index 4740819..d0bdc11 100644
--- a/Scripts/Editor/NodeEditorGUILayout.cs
+++ b/Scripts/Editor/NodeEditorGUILayout.cs
@@ -41,8 +41,18 @@ namespace XNodeEditor {
// Get data from [Input] attribute
XNode.Node.ShowBackingValue showBacking = XNode.Node.ShowBackingValue.Unconnected;
XNode.Node.InputAttribute inputAttribute;
- if (NodeEditorUtilities.GetAttrib(port.node.GetType(), property.name, out inputAttribute)) showBacking = inputAttribute.backingValue;
+ bool instancePortList = false;
+ if (NodeEditorUtilities.GetAttrib(port.node.GetType(), property.name, out inputAttribute)) {
+ instancePortList = inputAttribute.instancePortList;
+ showBacking = inputAttribute.backingValue;
+ }
+ if (instancePortList) {
+ Type type = GetType(property);
+ XNode.Node.ConnectionType connectionType = inputAttribute != null ? inputAttribute.connectionType : XNode.Node.ConnectionType.Multiple;
+ InstancePortList(property.name, type, property.serializedObject, port.direction, connectionType);
+ return;
+ }
switch (showBacking) {
case XNode.Node.ShowBackingValue.Unconnected:
// Display a label if port is connected
@@ -67,8 +77,18 @@ namespace XNodeEditor {
// Get data from [Output] attribute
XNode.Node.ShowBackingValue showBacking = XNode.Node.ShowBackingValue.Unconnected;
XNode.Node.OutputAttribute outputAttribute;
- if (NodeEditorUtilities.GetAttrib(port.node.GetType(), property.name, out outputAttribute)) showBacking = outputAttribute.backingValue;
+ bool instancePortList = false;
+ if (NodeEditorUtilities.GetAttrib(port.node.GetType(), property.name, out outputAttribute)) {
+ instancePortList = outputAttribute.instancePortList;
+ showBacking = outputAttribute.backingValue;
+ }
+ if (instancePortList) {
+ Type type = GetType(property);
+ XNode.Node.ConnectionType connectionType = outputAttribute != null ? outputAttribute.connectionType : XNode.Node.ConnectionType.Multiple;
+ InstancePortList(property.name, type, property.serializedObject, port.direction, connectionType);
+ return;
+ }
switch (showBacking) {
case XNode.Node.ShowBackingValue.Unconnected:
// Display a label if port is connected
@@ -105,6 +125,12 @@ namespace XNodeEditor {
}
}
+ private static System.Type GetType(SerializedProperty property) {
+ System.Type parentType = property.serializedObject.targetObject.GetType();
+ System.Reflection.FieldInfo fi = parentType.GetField(property.propertyPath);
+ return fi.FieldType;
+ }
+
/// Make a simple port field.
public static void PortField(XNode.NodePort port, params GUILayoutOption[] options) {
PortField(null, port, options);
@@ -259,7 +285,7 @@ namespace XNodeEditor {
} else EditorGUILayout.LabelField("[Out of bounds]");
} else {
- EditorGUILayout.LabelField(instancePorts[i].fieldName);
+ EditorGUILayout.LabelField(ObjectNames.NicifyVariableName(instancePorts[i].fieldName));
}
GUILayout.EndHorizontal();
diff --git a/Scripts/Node.cs b/Scripts/Node.cs
index 90b65e3..5179c32 100644
--- a/Scripts/Node.cs
+++ b/Scripts/Node.cs
@@ -212,11 +212,12 @@ namespace XNode {
public class InputAttribute : Attribute {
public ShowBackingValue backingValue;
public ConnectionType connectionType;
+ public bool instancePortList;
/// Mark a serializable field as an input port. You can access this through
/// Should we display the backing value for this port as an editor field?
/// Should we allow multiple connections?
- public InputAttribute(ShowBackingValue backingValue = ShowBackingValue.Unconnected, ConnectionType connectionType = ConnectionType.Multiple) {
+ public InputAttribute(ShowBackingValue backingValue = ShowBackingValue.Unconnected, ConnectionType connectionType = ConnectionType.Multiple, bool instancePortList = false) {
this.backingValue = backingValue;
this.connectionType = connectionType;
}
@@ -227,11 +228,12 @@ namespace XNode {
public class OutputAttribute : Attribute {
public ShowBackingValue backingValue;
public ConnectionType connectionType;
+ public bool instancePortList;
/// Mark a serializable field as an output port. You can access this through
/// Should we display the backing value for this port as an editor field?
/// Should we allow multiple connections?
- public OutputAttribute(ShowBackingValue backingValue = ShowBackingValue.Never, ConnectionType connectionType = ConnectionType.Multiple) {
+ public OutputAttribute(ShowBackingValue backingValue = ShowBackingValue.Never, ConnectionType connectionType = ConnectionType.Multiple, bool instancePortList = false) {
this.backingValue = backingValue;
this.connectionType = connectionType;
}