mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 07:53:26 +00:00
[.NET] Use ObjectID
when converting Variant
to GodotObject
(cherry picked from commit bfcc389e21
)
This commit is contained in:
parent
bdf4f38ac4
commit
f045c4c283
2 changed files with 14 additions and 1 deletions
|
@ -455,6 +455,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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue