mirror of
https://github.com/Siccity/xNode.git
synced 2026-02-06 15:24:55 +08:00
Added instancePortList field to Input and Output attributes.
This commit is contained in:
parent
9d08d2d172
commit
7ee89ba79c
@ -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;
|
||||
}
|
||||
|
||||
/// <summary> Make a simple port field. </summary>
|
||||
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();
|
||||
|
||||
@ -212,11 +212,12 @@ namespace XNode {
|
||||
public class InputAttribute : Attribute {
|
||||
public ShowBackingValue backingValue;
|
||||
public ConnectionType connectionType;
|
||||
public bool instancePortList;
|
||||
|
||||
/// <summary> Mark a serializable field as an input port. You can access this through <see cref="GetInputPort(string)"/> </summary>
|
||||
/// <param name="backingValue">Should we display the backing value for this port as an editor field? </param>
|
||||
/// <param name="connectionType">Should we allow multiple connections? </param>
|
||||
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;
|
||||
|
||||
/// <summary> Mark a serializable field as an output port. You can access this through <see cref="GetOutputPort(string)"/> </summary>
|
||||
/// <param name="backingValue">Should we display the backing value for this port as an editor field? </param>
|
||||
/// <param name="connectionType">Should we allow multiple connections? </param>
|
||||
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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user