diff --git a/editor/file_system/editor_file_system.cpp b/editor/file_system/editor_file_system.cpp index a8c2c180411..73b8f44f9d1 100644 --- a/editor/file_system/editor_file_system.cpp +++ b/editor/file_system/editor_file_system.cpp @@ -3420,24 +3420,17 @@ Ref EditorFileSystem::_load_resource_on_startup(ResourceFormatImporter ERR_FAIL_V_MSG(Ref(), vformat("Failed loading resource: %s. The file doesn't seem to exist.", p_path)); } - Ref res; - bool can_retry = true; - bool retry = true; - while (retry) { - retry = false; - - res = p_importer->load_internal(p_path, r_error, p_use_sub_threads, r_progress, p_cache_mode, can_retry); - - if (res.is_null() && can_retry) { - can_retry = false; - Error err = singleton->_reimport_file(p_path, HashMap(), "", nullptr, false); - if (err == OK) { - retry = true; - } - } + // Fail silently. Hopefully the resource is not yet imported. + Ref res = p_importer->load_internal(p_path, r_error, p_use_sub_threads, r_progress, p_cache_mode, true); + if (res.is_valid()) { + return res; } - return res; + // Retry after importing the resource. + if (singleton->_reimport_file(p_path, HashMap(), "", nullptr, false) != OK) { + return Ref(); + } + return p_importer->load_internal(p_path, r_error, p_use_sub_threads, r_progress, p_cache_mode, false); } bool EditorFileSystem::_should_skip_directory(const String &p_path) {