diff --git a/Scripts/Attributes/PortTypeOverrideAttribute.cs b/Scripts/Attributes/PortTypeOverrideAttribute.cs new file mode 100644 index 00000000..316ca2d9 --- /dev/null +++ b/Scripts/Attributes/PortTypeOverrideAttribute.cs @@ -0,0 +1,12 @@ +using System; +/// Overrides the ValueType of the Port, to have a ValueType different from the type of its serializable field +/// Especially useful in Dynamic Port Lists to create Value-Port Pairs with different type. +[AttributeUsage(AttributeTargets.Field)] +public class PortTypeOverrideAttribute : Attribute { + public Type type; + /// Overrides the ValueType of the Port + /// ValueType of the Port + public PortTypeOverrideAttribute(Type type) { + this.type = type; + } +} diff --git a/Scripts/Attributes/PortTypeOverrideAttribute.cs.meta b/Scripts/Attributes/PortTypeOverrideAttribute.cs.meta new file mode 100644 index 00000000..a5877598 --- /dev/null +++ b/Scripts/Attributes/PortTypeOverrideAttribute.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1410c1437e863ab4fac7a7428aaca35b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/NodePort.cs b/Scripts/NodePort.cs index b8656efc..1fbc62f8 100644 --- a/Scripts/NodePort.cs +++ b/Scripts/NodePort.cs @@ -79,6 +79,10 @@ public NodePort(FieldInfo fieldInfo) { _connectionType = (attribs[i] as Node.OutputAttribute).connectionType; _typeConstraint = (attribs[i] as Node.OutputAttribute).typeConstraint; } + // Override ValueType of the Port + if(attribs[i] is PortTypeOverrideAttribute) { + ValueType = (attribs[i] as PortTypeOverrideAttribute).type; + } } }