diff options
author | Rindbee <idleman@yeah.net> | 2022-12-18 08:05:36 +0800 |
---|---|---|
committer | Yuri Sizov <yuris@humnom.net> | 2023-04-26 14:51:00 +0200 |
commit | 4b4556179e541ef100202a1270e678f3bcac7fb6 (patch) | |
tree | 73f83908734d3da774445d1e5084cf56b6e7b7f3 /scene/resources | |
parent | b711b458701e3b227eb6347848071e190465080d (diff) |
Fix the uid field of the tscn/res file is lost when the external dependency is updated
(cherry picked from commit 41ac40c44c058b5f9aa0d033787b2acb8e8020ea)
Diffstat (limited to 'scene/resources')
-rw-r--r-- | scene/resources/resource_format_text.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp index 448e800900..c30e009356 100644 --- a/scene/resources/resource_format_text.cpp +++ b/scene/resources/resource_format_text.cpp @@ -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"); } } |