diff options
| author | Ignacio Etcheverry <ignalfonsore@gmail.com> | 2019-02-19 22:36:27 +0100 |
|---|---|---|
| committer | Ignacio Etcheverry <ignalfonsore@gmail.com> | 2019-02-19 22:38:22 +0100 |
| commit | 9421da57ad552e9004e9ca3d739d75b0c1efee03 (patch) | |
| tree | 9ff25829822164180c2edfcf847394ecbfa19c22 /modules/mono/mono_gd/gd_mono_utils.cpp | |
| parent | aa5b99821b23d74eafb49f4b0d2d86fe693a903c (diff) | |
| download | redot-engine-9421da57ad552e9004e9ca3d739d75b0c1efee03.tar.gz | |
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.
Diffstat (limited to 'modules/mono/mono_gd/gd_mono_utils.cpp')
| -rw-r--r-- | modules/mono/mono_gd/gd_mono_utils.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/modules/mono/mono_gd/gd_mono_utils.cpp b/modules/mono/mono_gd/gd_mono_utils.cpp index 3b97339fea..6cc1c8afc2 100644 --- a/modules/mono/mono_gd/gd_mono_utils.cpp +++ b/modules/mono/mono_gd/gd_mono_utils.cpp @@ -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); |
