diff options
author | kobewi <kobewi4e@gmail.com> | 2022-10-09 13:06:15 +0200 |
---|---|---|
committer | kobewi <kobewi4e@gmail.com> | 2022-10-09 13:06:15 +0200 |
commit | a38891dfb3851d0e119bc418994f9bbf1436be86 (patch) | |
tree | 8de86e24abc76f15892548e365d70abfff8aed30 /editor | |
parent | 880a0177d12463b612268afe95bd3d8dd565bf52 (diff) |
Fallback to ResourceLoader if can't find UID
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_file_system.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index 6f34c677db..747ac8126c 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -2259,7 +2259,7 @@ void EditorFileSystem::move_group_file(const String &p_path, const String &p_new ResourceUID::ID EditorFileSystem::_resource_saver_get_resource_id_for_path(const String &p_path, bool p_generate) { if (!p_path.is_resource_file() || p_path.begins_with(ProjectSettings::get_singleton()->get_project_data_path())) { - //saved externally (configuration file) or internal file, do not assign an ID. + // Saved externally (configuration file) or internal file, do not assign an ID. return ResourceUID::INVALID_ID; } @@ -2267,15 +2267,21 @@ ResourceUID::ID EditorFileSystem::_resource_saver_get_resource_id_for_path(const int cpos = -1; if (!singleton->_find_file(p_path, &fs, cpos)) { + // Fallback to ResourceLoader if filesystem cache fails (can happen during scanning etc.). + ResourceUID::ID fallback = ResourceLoader::get_resource_uid(p_path); + if (fallback != ResourceUID::INVALID_ID) { + return fallback; + } + if (p_generate) { - return ResourceUID::get_singleton()->create_id(); //just create a new one, we will be notified of save anyway and fetch the right UUID at that time, to keep things simple. + return ResourceUID::get_singleton()->create_id(); // Just create a new one, we will be notified of save anyway and fetch the right UUID at that time, to keep things simple. } else { return ResourceUID::INVALID_ID; } } else if (fs->files[cpos]->uid != ResourceUID::INVALID_ID) { return fs->files[cpos]->uid; } else if (p_generate) { - return ResourceUID::get_singleton()->create_id(); //just create a new one, we will be notified of save anyway and fetch the right UUID at that time, to keep things simple. + return ResourceUID::get_singleton()->create_id(); // Just create a new one, we will be notified of save anyway and fetch the right UUID at that time, to keep things simple. } else { return ResourceUID::INVALID_ID; } |