diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/InteropStructs.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/InteropStructs.cs index 7e5c01d0f88..c579d1cc2ac 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/InteropStructs.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/InteropStructs.cs @@ -447,6 +447,12 @@ namespace Godot.NativeInterop get => _data._m_obj_data.obj; } + public readonly ulong ObjectId + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get => _data._m_obj_data.id; + } + public void Dispose() { switch (Type) diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.cs index dc151e2c3ee..414f0a5d13a 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.cs @@ -485,7 +485,14 @@ namespace Godot.NativeInterop NativeFuncs.godotsharp_variant_as_rid(p_var); public static IntPtr ConvertToGodotObjectPtr(in godot_variant p_var) - => p_var.Type == Variant.Type.Object ? p_var.Object : IntPtr.Zero; + { + if (p_var.Type != Variant.Type.Object || p_var.ObjectId == 0) + { + return IntPtr.Zero; + } + + return NativeFuncs.godotsharp_instance_from_id(p_var.ObjectId); + } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static GodotObject ConvertToGodotObject(in godot_variant p_var)