You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-08 12:40:44 +00:00
Ability to change a resource UID from API
* Works for text, binary and imported resources * Allows better clean up of duplicate files. TODO (future PRs): * Use this API for assigning new UIDs to copied files. * Use this API for UID conflict on FS scanning (if more than one file has the same UID, the newer one(s) should get assigned a different UID).
This commit is contained in:
@@ -433,7 +433,7 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo
|
||||
}
|
||||
|
||||
if (!found_uid) {
|
||||
return true; //UUID not found, old format, reimport.
|
||||
return true; //UID not found, old format, reimport.
|
||||
}
|
||||
|
||||
Ref<ResourceImporter> importer = ResourceFormatImporter::get_singleton()->get_importer_by_name(importer_name);
|
||||
@@ -868,7 +868,7 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, Ref<DirAc
|
||||
}
|
||||
|
||||
if (fc->uid == ResourceUID::INVALID_ID) {
|
||||
// imported files should always have a UUID, so attempt to fetch it.
|
||||
// imported files should always have a UID, so attempt to fetch it.
|
||||
fi->uid = ResourceLoader::get_resource_uid(path);
|
||||
}
|
||||
|
||||
@@ -2319,14 +2319,14 @@ ResourceUID::ID EditorFileSystem::_resource_saver_get_resource_id_for_path(const
|
||||
}
|
||||
|
||||
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 UID 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 UID at that time, to keep things simple.
|
||||
} else {
|
||||
return ResourceUID::INVALID_ID;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user