diff options
author | Rindbee <idleman@yeah.net> | 2022-12-18 08:05:36 +0800 |
---|---|---|
committer | Rindbee <idleman@yeah.net> | 2023-01-22 09:53:46 +0800 |
commit | 41ac40c44c058b5f9aa0d033787b2acb8e8020ea (patch) | |
tree | 4db0035c739888f2439f82a29675d0fe2362ae31 /scene/resources/resource_format_text.cpp | |
parent | c3539b4561f9b4d7dc4ba1c5859217e7fbf9c6fe (diff) | |
download | redot-engine-41ac40c44c058b5f9aa0d033787b2acb8e8020ea.tar.gz |
Fix the uid field of the tscn/res file is lost when the external dependency is updated
Diffstat (limited to 'scene/resources/resource_format_text.cpp')
-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 0ba177f882..498f890734 100644 --- a/scene/resources/resource_format_text.cpp +++ b/scene/resources/resource_format_text.cpp @@ -920,14 +920,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"); } } |