mirror of https://github.com/godotengine/godot
[.NET] Use `ObjectID` when converting `Variant` to `GodotObject`
This commit is contained in:
parent
4c4e673344
commit
bfcc389e21
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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…
Reference in New Issue