MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / get_singleton_object

Method get_singleton_object

core/config/engine.cpp:345–356  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

343}
344
345Object *Engine::get_singleton_object(const StringName &p_name) const {
346 HashMap<StringName, Object *>::ConstIterator E = singleton_ptrs.find(p_name);
347 ERR_FAIL_COND_V_MSG(!E, nullptr, vformat("Failed to retrieve non-existent singleton '%s'.", p_name));
348
349#ifdef TOOLS_ENABLED
350 if (!is_editor_hint() && is_singleton_editor_only(p_name)) {
351 ERR_FAIL_V_MSG(nullptr, vformat("Can't retrieve singleton '%s' outside of editor.", p_name));
352 }
353#endif
354
355 return E->value;
356}
357
358bool Engine::is_singleton_user_created(const StringName &p_name) const {
359 ERR_FAIL_COND_V(!singleton_ptrs.has(p_name), false);

Callers 4

debugMethod · 0.45
RemoteDebuggerMethod · 0.45

Calls 2

vformatFunction · 0.85
findMethod · 0.45

Tested by

no test coverage detected