浏览代码

Merge pull request #92972 from ogapo/pr/warn-on-duplicate-uids

Editor: Warn on UID duplicates
Rémi Verschelde 11 月之前
父节点
当前提交
8ba3c2aeb4
共有 1 个文件被更改,包括 8 次插入0 次删除
  1. 8 0
      editor/editor_file_system.cpp

+ 8 - 0
editor/editor_file_system.cpp

@@ -1141,6 +1141,14 @@ void EditorFileSystem::_process_file_system(const ScannedDirectory *p_scan_dir,
 
 
 		if (fi->uid != ResourceUID::INVALID_ID) {
 		if (fi->uid != ResourceUID::INVALID_ID) {
 			if (ResourceUID::get_singleton()->has_id(fi->uid)) {
 			if (ResourceUID::get_singleton()->has_id(fi->uid)) {
+				// Restrict UID dupe warning to first-scan since we know there are no file moves going on yet.
+				if (first_scan) {
+					// Warn if we detect files with duplicate UIDs.
+					const String other_path = ResourceUID::get_singleton()->get_id_path(fi->uid);
+					if (other_path != path) {
+						WARN_PRINT(vformat("UID duplicate detected between %s and %s.", path, other_path));
+					}
+				}
 				ResourceUID::get_singleton()->set_id(fi->uid, path);
 				ResourceUID::get_singleton()->set_id(fi->uid, path);
 			} else {
 			} else {
 				ResourceUID::get_singleton()->add_id(fi->uid, path);
 				ResourceUID::get_singleton()->add_id(fi->uid, path);