You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-05 17:15:09 +00:00
Support marshaling generic Godot.Object
Allows using generic C# types in signals as long as they inherit from `Godot.Object`.
This commit is contained in:
@@ -266,6 +266,12 @@ Variant::Type managed_to_variant_type(const ManagedType &p_type, bool *r_nil_is_
|
|||||||
if (GDMonoUtils::Marshal::type_is_generic_icollection(reftype) || GDMonoUtils::Marshal::type_is_generic_ienumerable(reftype)) {
|
if (GDMonoUtils::Marshal::type_is_generic_icollection(reftype) || GDMonoUtils::Marshal::type_is_generic_ienumerable(reftype)) {
|
||||||
return Variant::ARRAY;
|
return Variant::ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GodotObject
|
||||||
|
GDMonoClass *type_class = p_type.type_class;
|
||||||
|
if (CACHED_CLASS(GodotObject)->is_assignable_from(type_class)) {
|
||||||
|
return Variant::OBJECT;
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
@@ -450,6 +456,11 @@ MonoObject *variant_to_mono_object_of_genericinst(const Variant &p_var, GDMonoCl
|
|||||||
return GDMonoUtils::create_managed_from(p_var.operator Array(), godot_array_class);
|
return GDMonoUtils::create_managed_from(p_var.operator Array(), godot_array_class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GodotObject
|
||||||
|
if (CACHED_CLASS(GodotObject)->is_assignable_from(p_type_class)) {
|
||||||
|
return GDMonoUtils::unmanaged_get_managed(p_var.operator Object *());
|
||||||
|
}
|
||||||
|
|
||||||
ERR_FAIL_V_MSG(nullptr, "Attempted to convert Variant to unsupported generic type: '" +
|
ERR_FAIL_V_MSG(nullptr, "Attempted to convert Variant to unsupported generic type: '" +
|
||||||
p_type_class->get_full_name() + "'.");
|
p_type_class->get_full_name() + "'.");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user