diff --git a/Scripts/NodePort.cs b/Scripts/NodePort.cs index 14c3b7d..7f5be5c 100644 --- a/Scripts/NodePort.cs +++ b/Scripts/NodePort.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Reflection; using UnityEngine; @@ -147,9 +147,18 @@ namespace XNode { /// Return the output value of the first connected port. Returns null if none found or invalid. /// - public T GetInputValue() { - object obj = GetInputValue(); - return obj is T ? (T) obj : default(T); + public T GetInputValue () + { + object obj = GetInputValue (); + + + if ( obj.GetType () == typeof ( T ) ) + return (T) obj; + + if ( typeof ( T ).IsCastableFrom ( obj.GetType () ) && obj.TryCast ( out object t ) ) + return (T) t; + + return default; } /// Return the output values of all connected ports.