From bc47bacc9efc92c08c6b512ec10ac013a4aaed4b Mon Sep 17 00:00:00 2001 From: Raul Santos Date: Mon, 18 Oct 2021 02:57:44 +0200 Subject: Fix marshaling generic Godot.Object in C# --- modules/mono/mono_gd/gd_mono_marshal.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'modules/mono/mono_gd') diff --git a/modules/mono/mono_gd/gd_mono_marshal.cpp b/modules/mono/mono_gd/gd_mono_marshal.cpp index f8736dd043..1904634132 100644 --- a/modules/mono/mono_gd/gd_mono_marshal.cpp +++ b/modules/mono/mono_gd/gd_mono_marshal.cpp @@ -1256,6 +1256,17 @@ Variant mono_object_to_variant_impl(MonoObject *p_obj, const ManagedType &p_type GDMonoUtils::Marshal::array_get_element_type(reftype, &elem_reftype); return system_generic_list_to_Array_variant(p_obj, p_type.type_class, elem_reftype); } + + // GodotObject + GDMonoClass *type_class = p_type.type_class; + if (CACHED_CLASS(GodotObject)->is_assignable_from(type_class)) { + Object *ptr = unbox(CACHED_FIELD(GodotObject, ptr)->get_value(p_obj)); + if (ptr != nullptr) { + RefCounted *rc = Object::cast_to(ptr); + return rc ? Variant(Ref(rc)) : Variant(ptr); + } + return Variant(); + } } break; } -- cgit v1.2.3