You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-19 14:31:59 +00:00
C#: Add 'Singleton' property to singleton wrapper class
This property returns an instance of the singleton. The purpose of this is to allow using methods from the base class like 'Connect'. Since all Godot singletons inherit Object, the type of the returned instance is Godot.Object.
This commit is contained in:
@@ -374,6 +374,11 @@ GDMonoClass *type_get_proxy_class(const StringName &p_type) {
|
||||
|
||||
GDMonoClass *klass = GDMono::get_singleton()->get_core_api_assembly()->get_class(BINDINGS_NAMESPACE, class_name);
|
||||
|
||||
if (klass && klass->is_static()) {
|
||||
// A static class means this is a Godot singleton class. If an instance is needed we use Godot.Object.
|
||||
return mono_cache.class_GodotObject;
|
||||
}
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
if (!klass) {
|
||||
return GDMono::get_singleton()->get_editor_api_assembly()->get_class(BINDINGS_NAMESPACE, class_name);
|
||||
|
||||
Reference in New Issue
Block a user