1
0
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:
Thor Brigsted 2023-07-10 15:52:05 +02:00 committed by GitHub
commit 82f7887931
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 0 deletions

View 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;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1410c1437e863ab4fac7a7428aaca35b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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;
}
}
}