mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-20 01:06:01 +08:00
Merge pull request #368 from guizix/PortTypeOverride
Ability to override ValueType of a Port
This commit is contained in:
commit
82f7887931
12
Scripts/Attributes/PortTypeOverrideAttribute.cs
Normal file
12
Scripts/Attributes/PortTypeOverrideAttribute.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
/// <summary> Overrides the ValueType of the Port, to have a ValueType different from the type of its serializable field </summary>
|
||||
/// <remarks> Especially useful in Dynamic Port Lists to create Value-Port Pairs with different type. </remarks>
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class PortTypeOverrideAttribute : Attribute {
|
||||
public Type type;
|
||||
/// <summary> Overrides the ValueType of the Port </summary>
|
||||
/// <param name="type">ValueType of the Port</param>
|
||||
public PortTypeOverrideAttribute(Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
11
Scripts/Attributes/PortTypeOverrideAttribute.cs.meta
Normal file
11
Scripts/Attributes/PortTypeOverrideAttribute.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1410c1437e863ab4fac7a7428aaca35b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -79,6 +79,10 @@ namespace XNode {
|
||||
_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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user