diff --git a/Scripts/Node.cs b/Scripts/Node.cs index 6744cc5..704e99d 100644 --- a/Scripts/Node.cs +++ b/Scripts/Node.cs @@ -51,6 +51,8 @@ namespace XNode { Strict, /// Allow connections where output value type is assignable from input value type (eg. Object --> ScriptableObject) InheritedInverse, + /// Allow connections where output value type is assignable from input value or input value type is assignable from output value type + InheritedAny } #region Obsolete diff --git a/Scripts/NodePort.cs b/Scripts/NodePort.cs index 692e63f..f7d6f97 100644 --- a/Scripts/NodePort.cs +++ b/Scripts/NodePort.cs @@ -273,10 +273,12 @@ namespace XNode { 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; + if (input.typeConstraint == XNode.Node.TypeConstraint.InheritedAny && !input.ValueType.IsAssignableFrom(output.ValueType) && !output.ValueType.IsAssignableFrom(input.ValueType)) return false; // Check output type constraints if (output.typeConstraint == XNode.Node.TypeConstraint.Inherited && !input.ValueType.IsAssignableFrom(output.ValueType)) return false; if (output.typeConstraint == XNode.Node.TypeConstraint.Strict && input.ValueType != output.ValueType) return false; if (output.typeConstraint == XNode.Node.TypeConstraint.InheritedInverse && !output.ValueType.IsAssignableFrom(input.ValueType)) return false; + if (output.typeConstraint == XNode.Node.TypeConstraint.InheritedAny && !input.ValueType.IsAssignableFrom(output.ValueType) && !output.ValueType.IsAssignableFrom(input.ValueType)) return false; // Success return true; }