| 343 | } |
| 344 | |
| 345 | Object *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 | |
| 358 | bool Engine::is_singleton_user_created(const StringName &p_name) const { |
| 359 | ERR_FAIL_COND_V(!singleton_ptrs.has(p_name), false); |
no test coverage detected