diff options
author | George L. Albany <Megacake1234@gmail.com> | 2024-11-11 16:19:19 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-11 16:19:19 +0000 |
commit | 5094c2a5f7d506b0e685120f14d1df42e1e9d495 (patch) | |
tree | a10abf56ba93705731da1aaf338f2cf21403c6ad /core/io/resource_loader.cpp | |
parent | e7894c2c4efdd51049a21af4892005381fe57cd6 (diff) | |
parent | 62fbec9f6f0722a1f9825c17f073742932082228 (diff) | |
download | redot-engine-5094c2a5f7d506b0e685120f14d1df42e1e9d495.tar.gz |
Merge pull request #853 from Spartan322/merge/0f5f3bc
Merge commit godotengine/godot@0f5f3bc
Diffstat (limited to 'core/io/resource_loader.cpp')
-rw-r--r-- | core/io/resource_loader.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index 97e6f6da06..08b6b6e982 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -284,13 +284,13 @@ Ref<Resource> ResourceLoader::_load(const String &p_path, const String &p_origin load_paths_stack.push_back(original_path); // Try all loaders and pick the first match for the type hint - bool found = false; + bool loader_found = false; Ref<Resource> res; for (int i = 0; i < loader_count; i++) { if (!loader[i]->recognize_path(p_path, p_type_hint)) { continue; } - found = true; + loader_found = true; res = loader[i]->load(p_path, original_path, r_error, p_use_sub_threads, r_progress, p_cache_mode); if (!res.is_null()) { break; @@ -305,15 +305,24 @@ Ref<Resource> ResourceLoader::_load(const String &p_path, const String &p_origin return res; } - ERR_FAIL_COND_V_MSG(found, Ref<Resource>(), - vformat("Failed loading resource: %s. Make sure resources have been imported by opening the project in the editor at least once.", p_path)); + if (!loader_found) { + if (r_error) { + *r_error = ERR_FILE_UNRECOGNIZED; + } + ERR_FAIL_V_MSG(Ref<Resource>(), vformat("No loader found for resource: %s (expected type: %s)", p_path, p_type_hint)); + } #ifdef TOOLS_ENABLED Ref<FileAccess> file_check = FileAccess::create(FileAccess::ACCESS_RESOURCES); - ERR_FAIL_COND_V_MSG(!file_check->file_exists(p_path), Ref<Resource>(), vformat("Resource file not found: %s (expected type: %s)", p_path, p_type_hint)); + if (!file_check->file_exists(p_path)) { + if (r_error) { + *r_error = ERR_FILE_NOT_FOUND; + } + ERR_FAIL_V_MSG(Ref<Resource>(), vformat("Resource file not found: %s (expected type: %s)", p_path, p_type_hint)); + } #endif - ERR_FAIL_V_MSG(Ref<Resource>(), vformat("No loader found for resource: %s (expected type: %s)", p_path, p_type_hint)); + ERR_FAIL_V_MSG(Ref<Resource>(), vformat("Failed loading resource: %s. Make sure resources have been imported by opening the project in the editor at least once.", p_path)); } // This implementation must allow re-entrancy for a task that started awaiting in a deeper stack frame. |