-
-
Notifications
You must be signed in to change notification settings - Fork 21.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Core: Do not generate *.uid
files for JSON, certificates, and translations
#99540
Core: Do not generate *.uid
files for JSON, certificates, and translations
#99540
Conversation
b205139
to
98398a4
Compare
@@ -105,6 +105,9 @@ class ResourceFormatLoaderJSON : public ResourceFormatLoader { | |||
virtual void get_recognized_extensions(List<String> *p_extensions) const override; | |||
virtual bool handles_type(const String &p_type) const override; | |||
virtual String get_resource_type(const String &p_path) const override; | |||
// Treat JSON as a text file, do not generate a `*.json.uid` file. | |||
virtual ResourceUID::ID get_resource_uid(const String &p_path) const override { return ResourceUID::INVALID_ID; } | |||
virtual bool has_custom_uid_support() const override { return true; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that both overrides are required. This may seem odd, since in fact JSON does not have a UID. But we define "support" for custom UID... which is invalid. It might make sense to separate these three lines with a blank line for better readability.
godot/core/io/resource_loader.cpp
Lines 115 to 126 in f952bfe
ResourceUID::ID ResourceFormatLoader::get_resource_uid(const String &p_path) const { | |
int64_t uid = ResourceUID::INVALID_ID; | |
if (has_custom_uid_support()) { | |
GDVIRTUAL_CALL(_get_resource_uid, p_path, uid); | |
} else { | |
Ref<FileAccess> file = FileAccess::open(p_path + ".uid", FileAccess::READ); | |
if (file.is_valid()) { | |
uid = ResourceUID::get_singleton()->text_to_id(file->get_line()); | |
} | |
} | |
return uid; | |
} |
Lines 1457 to 1465 in f952bfe
void EditorNode::ensure_uid_file(const String &p_new_resource_path) { | |
if (ResourceLoader::exists(p_new_resource_path) && !ResourceLoader::has_custom_uid_support(p_new_resource_path) && !FileAccess::exists(p_new_resource_path + ".uid")) { | |
Ref<FileAccess> f = FileAccess::open(p_new_resource_path + ".uid", FileAccess::WRITE); | |
if (f.is_valid()) { | |
const ResourceUID::ID id = ResourceUID::get_singleton()->create_id(); | |
f->store_line(ResourceUID::get_singleton()->id_to_text(id)); | |
} | |
} | |
} |
godot/editor/editor_file_system.cpp
Lines 1263 to 1270 in f952bfe
if (fi->uid == ResourceUID::INVALID_ID && ResourceLoader::exists(path) && !ResourceLoader::has_custom_uid_support(path) && !FileAccess::exists(path + ".uid")) { | |
// Create a UID. | |
Ref<FileAccess> f = FileAccess::open(path + ".uid", FileAccess::WRITE); | |
if (f.is_valid()) { | |
fi->uid = ResourceUID::get_singleton()->create_id(); | |
f->store_line(ResourceUID::get_singleton()->id_to_text(fi->uid)); | |
} | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could make it into a macro called DISABLE_UID
or something. These 2 lines will be the same for every class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is redundant for now. But we may reconsider this in the future if more exceptions are added.
I checked all
|
Yeah I think disabling We can always re-assess if some users report issues due to not having UIDs for those or |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me.
98398a4
to
eb216c6
Compare
eb216c6
to
b91bacb
Compare
*.json.uid
files*.uid
files for JSON, certificates, and translations
Thanks! |
*.uid
files #99514.