diff --git a/Source/Engine/Engine/NativeInterop.Unmanaged.cs b/Source/Engine/Engine/NativeInterop.Unmanaged.cs index 574b74580..e99276a4e 100644 --- a/Source/Engine/Engine/NativeInterop.Unmanaged.cs +++ b/Source/Engine/Engine/NativeInterop.Unmanaged.cs @@ -1271,6 +1271,9 @@ namespace FlaxEngine.Interop case Type _ when type == typeof(IntPtr): monoType = MTypes.Ptr; break; + case Type _ when type.IsPointer: + monoType = MTypes.Ptr; + break; case Type _ when type.IsEnum: monoType = MTypes.Enum; break; diff --git a/Source/Engine/Engine/NativeInterop.cs b/Source/Engine/Engine/NativeInterop.cs index 30ce4d39f..9548c3f59 100644 --- a/Source/Engine/Engine/NativeInterop.cs +++ b/Source/Engine/Engine/NativeInterop.cs @@ -1112,11 +1112,9 @@ namespace FlaxEngine.Interop internal static void ToManagedPointer(ref IntPtr managedValue, IntPtr nativePtr, bool byRef) { - Type type = typeof(T); - byRef |= type.IsByRef; // Is this needed? - if (type.IsByRef) - Assert.IsTrue(type.GetElementType().IsValueType); - managedValue = byRef ? nativePtr : Unsafe.Read(nativePtr.ToPointer()); + if (byRef) + nativePtr = Unsafe.Read(nativePtr.ToPointer()); + managedValue = nativePtr; } internal static void ToManagedHandle(ref ManagedHandle managedValue, IntPtr nativePtr, bool byRef) diff --git a/Source/Engine/Scripting/ManagedCLR/MUtils.cpp b/Source/Engine/Scripting/ManagedCLR/MUtils.cpp index be8e10fab..52d049403 100644 --- a/Source/Engine/Scripting/ManagedCLR/MUtils.cpp +++ b/Source/Engine/Scripting/ManagedCLR/MUtils.cpp @@ -1208,6 +1208,10 @@ void* MUtils::VariantToManagedArgPtr(Variant& value, MType* type, bool& failed) object = nullptr; return object; } + case MTypes::Ptr: + if (value.Type.Type == VariantType::Null) + return nullptr; + return (void*)value; default: break; }