diff --git a/PorygonSharp/UserData/UserData.cs b/PorygonSharp/UserData/UserData.cs index e0e070f..10f6b0c 100644 --- a/PorygonSharp/UserData/UserData.cs +++ b/PorygonSharp/UserData/UserData.cs @@ -134,6 +134,8 @@ namespace PorygonSharp.UserData var expectedType = scriptType.ResolveType(); if (expectedType.IsAssignableFrom(Type)) return true; + if (Type.IsAssignableFrom(expectedType)) + return true; if (_implicitCasts.ContainsKey(expectedType)) return true; if (isExplicit && _explicitCasts.ContainsKey(expectedType)) @@ -149,6 +151,8 @@ namespace PorygonSharp.UserData var objType = obj.GetType(); if (expectedType.IsAssignableFrom(objType)) return objPtr; + if (objType.IsAssignableFrom(expectedType)) + return objPtr; if (_implicitCasts.TryGetValue(expectedType, out var func)) { var castVal = func.Invoke(null, new[] {obj});