Skip to content

Commit

Permalink
Merge pull request #70234 from Rindbee/fix-uid-lost
Browse files Browse the repository at this point in the history
Fix the uid field of the tscn/res file is lost when the external dependency is updated
  • Loading branch information
akien-mga committed Apr 25, 2023
2 parents 6aac8af + 41ac40c commit bbecc8a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions scene/resources/resource_format_text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -946,14 +946,24 @@ Error ResourceLoaderText::rename_dependencies(Ref<FileAccess> p_f, const String
} else {
if (fw.is_null()) {
fw = FileAccess::open(p_path + ".depren", FileAccess::WRITE);

if (res_uid == ResourceUID::INVALID_ID) {
res_uid = ResourceSaver::get_resource_id_for_path(p_path);
}

String uid_text = "";
if (res_uid != ResourceUID::INVALID_ID) {
uid_text = " uid=\"" + ResourceUID::get_singleton()->id_to_text(res_uid) + "\"";
}

if (is_scene) {
fw->store_line("[gd_scene load_steps=" + itos(resources_total) + " format=" + itos(FORMAT_VERSION) + "]\n");
fw->store_line("[gd_scene load_steps=" + itos(resources_total) + " format=" + itos(FORMAT_VERSION) + uid_text + "]\n");
} else {
String script_res_text;
if (!script_class.is_empty()) {
script_res_text = "script_class=\"" + script_class + "\" ";
}
fw->store_line("[gd_resource type=\"" + res_type + "\" " + script_res_text + "load_steps=" + itos(resources_total) + " format=" + itos(FORMAT_VERSION) + "]\n");
fw->store_line("[gd_resource type=\"" + res_type + "\" " + script_res_text + "load_steps=" + itos(resources_total) + " format=" + itos(FORMAT_VERSION) + uid_text + "]\n");
}
}

Expand Down

0 comments on commit bbecc8a

Please sign in to comment.