Skip to content

Commit

Permalink
Add options to control generate uid files or not.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daylily-Zeleen committed Feb 15, 2025
1 parent 96cdbbe commit db6017a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
6 changes: 6 additions & 0 deletions doc/classes/ProjectSettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,12 @@
<member name="editor/naming/script_name_casing" type="int" setter="" getter="" default="0">
When generating script file names from the selected node, set the type of casing to use in this project. This is mostly an editor setting.
</member>
<member name="editor/resource/generate_uid_files" type="bool" setter="" getter="" default="true">
If [code]true[/code], editor will generate ".uid" files for resources which have not custom uid support.
</member>
<member name="editor/resource/generate_uid_files_for_addons" type="bool" setter="" getter="" default="false">
If [code]false[/code], editor will not generate ".uid" files for resources which local in "res://addons".
</member>
<member name="editor/run/main_run_args" type="String" setter="" getter="" default="&quot;&quot;">
The command-line arguments to append to Godot's own command line when running the project. This doesn't affect the editor itself.
It is possible to make another executable run Godot by using the [code]%command%[/code] placeholder. The placeholder will be replaced with Godot's own command line. Program-specific arguments should be placed [i]before[/i] the placeholder, whereas Godot-specific arguments should be placed [i]after[/i] the placeholder.
Expand Down
18 changes: 11 additions & 7 deletions editor/editor_file_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1330,14 +1330,18 @@ void EditorFileSystem::_process_file_system(const ScannedDirectory *p_scan_dir,

if (ResourceLoader::should_create_uid_file(path)) {
// Create a UID file and new UID, if it's invalid.
Ref<FileAccess> f = FileAccess::open(path + ".uid", FileAccess::WRITE);
if (f.is_valid()) {
if (fi->uid == ResourceUID::INVALID_ID) {
fi->uid = ResourceUID::get_singleton()->create_id();
} else {
WARN_PRINT(vformat("Missing .uid file for path \"%s\". The file was re-created from cache.", path));
bool generate_uid_files = GLOBAL_GET("editor/resource/generate_uid_files");
bool generate_uid_files_for_addons = GLOBAL_GET("editor/resource/generate_uid_files_for_addons");
if (generate_uid_files && (generate_uid_files_for_addons || !path.begins_with("res://addons/"))) {
Ref<FileAccess> f = FileAccess::open(path + ".uid", FileAccess::WRITE);
if (f.is_valid()) {
if (fi->uid == ResourceUID::INVALID_ID) {
fi->uid = ResourceUID::get_singleton()->create_id();
} else {
WARN_PRINT(vformat("Missing .uid file for path \"%s\". The file was re-created from cache.", path));
}
f->store_line(ResourceUID::get_singleton()->id_to_text(fi->uid));
}
f->store_line(ResourceUID::get_singleton()->id_to_text(fi->uid));
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions editor/register_editor_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,9 @@ void register_editor_types() {
EditorHelp::init_gdext_pointers();

OS::get_singleton()->benchmark_end_measure("Editor", "Register Types");

GLOBAL_DEF("editor/resource/generate_uid_files", true);
GLOBAL_DEF("editor/resource/generate_uid_files_for_addons", false);
}

void unregister_editor_types() {
Expand Down

0 comments on commit db6017a

Please sign in to comment.