diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index 7cc91ef4318..04fd641f244 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -1196,6 +1196,20 @@ bool ResourceLoader::has_custom_uid_support(const String &p_path) { return false; } +bool ResourceLoader::should_create_uid_file(const String &p_path) { + const String local_path = _validate_local_path(p_path); + if (FileAccess::exists(local_path + ".uid")) { + return false; + } + + for (int i = 0; i < loader_count; i++) { + if (loader[i]->recognize_path(local_path)) { + return !loader[i]->has_custom_uid_support(); + } + } + return false; +} + String ResourceLoader::_path_remap(const String &p_path, bool *r_translation_remapped) { String new_path = p_path; diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h index 56052b6a6fc..10a82e811d0 100644 --- a/core/io/resource_loader.h +++ b/core/io/resource_loader.h @@ -246,6 +246,7 @@ public: static String get_resource_script_class(const String &p_path); static ResourceUID::ID get_resource_uid(const String &p_path); static bool has_custom_uid_support(const String &p_path); + static bool should_create_uid_file(const String &p_path); static void get_dependencies(const String &p_path, List *p_dependencies, bool p_add_types = false); static Error rename_dependencies(const String &p_path, const HashMap &p_map); static bool is_import_valid(const String &p_path); diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index 1db6c2a188e..2d10e4305ea 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -1263,7 +1263,7 @@ void EditorFileSystem::_process_file_system(const ScannedDirectory *p_scan_dir, } } - if (ResourceLoader::exists(path) && !ResourceLoader::has_custom_uid_support(path) && !FileAccess::exists(path + ".uid")) { + if (ResourceLoader::should_create_uid_file(path)) { // Create a UID file and new UID, if it's invalid. Ref f = FileAccess::open(path + ".uid", FileAccess::WRITE); if (f.is_valid()) { @@ -2345,7 +2345,7 @@ void EditorFileSystem::update_files(const Vector &p_script_paths) { ResourceUID::get_singleton()->update_cache(); } else { - if (ResourceLoader::exists(file) && !ResourceLoader::has_custom_uid_support(file) && !FileAccess::exists(file + ".uid")) { + if (ResourceLoader::should_create_uid_file(file)) { Ref f = FileAccess::open(file + ".uid", FileAccess::WRITE); if (f.is_valid()) { const ResourceUID::ID id = ResourceUID::get_singleton()->create_id();