diff --git a/Scripts/Node.cs b/Scripts/Node.cs index 27e32c7..fa196de 100644 --- a/Scripts/Node.cs +++ b/Scripts/Node.cs @@ -49,6 +49,8 @@ namespace XNode { Inherited, /// Allow only similar types Strict, + /// Allow similar and inherited types but checks inheritance in reverse + InheritedInverse, } #region Obsolete diff --git a/Scripts/NodePort.cs b/Scripts/NodePort.cs index 1000b23..5ce980c 100644 --- a/Scripts/NodePort.cs +++ b/Scripts/NodePort.cs @@ -259,9 +259,11 @@ namespace XNode { // Check input type constraints if (input.typeConstraint == XNode.Node.TypeConstraint.Inherited && !input.ValueType.IsAssignableFrom(output.ValueType)) return false; if (input.typeConstraint == XNode.Node.TypeConstraint.Strict && input.ValueType != output.ValueType) return false; + if (input.typeConstraint == XNode.Node.TypeConstraint.InheritedInverse && !output.ValueType.IsAssignableFrom(input.ValueType)) return false; // Check output type constraints if (output.typeConstraint == XNode.Node.TypeConstraint.Inherited && !output.ValueType.IsAssignableFrom(input.ValueType)) return false; if (output.typeConstraint == XNode.Node.TypeConstraint.Strict && output.ValueType != input.ValueType) return false; + if (output.typeConstraint == XNode.Node.TypeConstraint.InheritedInverse && !input.ValueType.IsAssignableFrom(output.ValueType)) return false; // Success return true; }