Merge pull request #92345 from mihe/classdb-extension-editor-classes

Fix `ClassDB` not checking for editor classes properly
This commit is contained in:
Rémi Verschelde 2024-05-28 15:49:23 +02:00
commit 760e30a4de
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -505,7 +505,7 @@ Object *ClassDB::_instantiate_internal(const StringName &p_class, bool p_require
ERR_FAIL_NULL_V_MSG(ti->creation_func, nullptr, "Class '" + String(p_class) + "' or its base class cannot be instantiated."); ERR_FAIL_NULL_V_MSG(ti->creation_func, nullptr, "Class '" + String(p_class) + "' or its base class cannot be instantiated.");
} }
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
if (ti->api == API_EDITOR && !Engine::get_singleton()->is_editor_hint()) { if ((ti->api == API_EDITOR || ti->api == API_EDITOR_EXTENSION) && !Engine::get_singleton()->is_editor_hint()) {
ERR_PRINT("Class '" + String(p_class) + "' can only be instantiated by editor."); ERR_PRINT("Class '" + String(p_class) + "' can only be instantiated by editor.");
return nullptr; return nullptr;
} }
@ -664,7 +664,7 @@ bool ClassDB::can_instantiate(const StringName &p_class) {
return scr.is_valid() && scr->is_valid() && !scr->is_abstract(); return scr.is_valid() && scr->is_valid() && !scr->is_abstract();
} }
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
if (ti->api == API_EDITOR && !Engine::get_singleton()->is_editor_hint()) { if ((ti->api == API_EDITOR || ti->api == API_EDITOR_EXTENSION) && !Engine::get_singleton()->is_editor_hint()) {
return false; return false;
} }
#endif #endif
@ -684,7 +684,7 @@ bool ClassDB::is_virtual(const StringName &p_class) {
return scr.is_valid() && scr->is_valid() && scr->is_abstract(); return scr.is_valid() && scr->is_valid() && scr->is_abstract();
} }
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
if (ti->api == API_EDITOR && !Engine::get_singleton()->is_editor_hint()) { if ((ti->api == API_EDITOR || ti->api == API_EDITOR_EXTENSION) && !Engine::get_singleton()->is_editor_hint()) {
return false; return false;
} }
#endif #endif