1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Add ability to register singletons from engine API

* Exposed functions in Engine to register and unregister singletons.
* Added the concept of user singletons, which can be removed (the system ones can't).
This commit is contained in:
reduz
2021-08-24 19:03:10 -03:00
parent ca7f53dd25
commit e2f8df8c5b
5 changed files with 90 additions and 11 deletions

View File

@@ -42,6 +42,7 @@ public:
StringName name;
Object *ptr;
StringName class_name; //used for binding generation hinting
bool user_created = false;
Singleton(const StringName &p_name = StringName(), Object *p_ptr = nullptr, const StringName &p_class_name = StringName());
};
@@ -109,8 +110,10 @@ public:
void add_singleton(const Singleton &p_singleton);
void get_singletons(List<Singleton> *p_singletons);
bool has_singleton(const String &p_name) const;
Object *get_singleton_object(const String &p_name) const;
bool has_singleton(const StringName &p_name) const;
Object *get_singleton_object(const StringName &p_name) const;
void remove_singleton(const StringName &p_name);
bool is_singleton_user_created(const StringName &p_name) const;
#ifdef TOOLS_ENABLED
_FORCE_INLINE_ void set_editor_hint(bool p_enabled) { editor_hint = p_enabled; }