-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Universalize UID support in all resource types #97352
Conversation
As someone who spent some time working on the refactoring problems and thinking about the UID system I fully support this approach. This will need some code in the filesystem dock to move the To make sure, refactoring paths file by file will no longer be needed, means that users should be encouraged to hardcode uids instead of paths, right? What do you mean by "editor refactoring not yet supported"? Significant issue that will not be fixed by this: #95637 This comes from the problem that paths for extraction from imported 3d files, stored as import options, currently do not support uids at all, nor do they work with the refactoring logic in the filesystem dock. I've though about this a bit but am unsure (maybe store uid as a hidden import option?), but it seems like paths in |
Agree that this is important: hardcoded paths is one of the biggest issues with the advanced importer, especially given that it causes failed imports or even outright engine crashes in some cases if the dependent files are missing. Allowing .import files to reference by UID is blocking some workflow improvements such as #86430 so it would be good to get this fixed in 4.4 |
@lyuma this seems to be a separate issue that will need a separate fix |
This is a great step forward, but I think your assessment about meta files is a bit disingenuous. Import files already contain editor-relevant metadata, and if in the future there's a need for saving anything else about code files, then you'll be in a situation where you either have to add another secondary file, rename the uid extension, or have a disconnect between the file intended type and it's content. I think it would be preferable to future proof a bit here, and allow for meta files that are general and flexible enough to avoid needing more as hoc solutions going forward. |
@JoNax97 If you ask me and I could redesign the engine from scratch, I would just have used generic metadata files for everything. Because that's not possible and the other formats already contain their own stuff, and their own metadata, this is the simplest solution for that. |
I understand your point. Maybe this could be the first step in a progressive migration path. |
@JoNax97 AFAIK that is probably Godot 5 material, so not likely to happen for a long time. We need to commit to a stable engine before major changes like this happening again. |
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.
Very surface-level documentation notes.
Why do _get_resource_uid
and _has_custom_uid_support
have to be two separate methods? Would it not be possible to verify if only _get_resource_uid
is overridden, and/or check if it returns 0
?
Did I understand correctly that it will be illegal to add uid files to gitignore? |
@arkology I would not do it 😆 |
I too would like to vote to make this more like a generic metadata file. Currently I'm trying to add "pack file tags" to assets to facilitate the pack file exporting workflow in godot (godotengine/godot-proposals#10580). The initial roadblock I've encountered is there's no real way to add metadata to PackedScenes [.tscn files] and GDScripts. As a proof of concept I added the ability for PackedScenes and GDScripts to have .import files to make it possible to save custom metadata for those assets. I had to edit some logic around how godot handles .import files, but it works. Having dedicated metadata files could be a better alternative, so it would be great though if you could expand the scope of this effort to make it a little more generic. It would make it significantly more futureproof. |
The Godot philosophy is that the solution should follow the problem. I think a more palatable approach (less likely to break assumptions) would be to add a place in the .tscn format for metadata to be written. That would solve that specific sub-problem scripts like .gd and .gdshader are a bit more complicated, because the code is human-readable, but you could imagine attaching something bulky like a texture into the metadata fields. Imagine for example, a plugin that assigns icons to scripts in metadata. If this image were dumped in base64 format into an annotation like If you limit script metadata to resource references and text strings, it could still be feasible to add annotations to scripts, but it wouldn't generalizable to 100% of cases, so this could be unexpected. There's actually a funky example in Unity which is similar to what you describe. Unity shaders can be in text format like in Godot. However, there is a feature where a default texture can be assigned for a given texture slot. Unity actually puts that texture reference into the .shader.meta file. In Godot, it would not be feasible to put a texture into the body of a shader, and I can see the appeal to having a .meta file to store this type of info, as in these other engines. My in-depth explanation of the problem with using .import for native formats (copied from RocketChat)
|
A future PR will inevitably need to store more data, the simplest solution will add another string after the UID, and eventually the Godot metadata format will become ill-defined text files with .uid extension. I'm calling it now. 🙂 |
It's easy enough to rename the extension in the future if we need, and have some compatibility code to handle the transition gracefully (keeping support for reading the old format, and adding support for converting to the new format). So there's no need to future proof and bikeshed now. |
@huwpascoe Please check the FAQ I wrote, metadata does not make sense because:
If at some point you want to have metadata, it will have to be done in a different way. |
That's okay, Akien's response was convincing enough. I probably should've replied with more than an emote! I do have a question though, sometimes assets are marked as don't import and show up as a little x icon, or maybe they'd be set for importing again later. Does the .uid handle this edge case? |
@huwpascoe I think it should be fine, since these is in practice for assets that are not imported |
Changes made:
This PR is now ready for review! |
Does that mean it no longer slow af to rename files when there’s a lot of files in the project?( 10k, 20k) |
@reduz Would it be worth adding editor functionality to resolve UID issues like this too? I have a project that I created in 4.3.dev 3 exhibiting this problem with UID's I think the function might be generating duplicates higher than it should be. |
@RevoluPowered Do you have an open issue about this? I feel that is unrelated. |
May I suggest a deterministic initial creation of the UID based on This will mitigate many, many cases of evil twin conflicts (that come when a file is checked in without its UID file) When two git users end up committing their own locally generated .uid files, and work a few changesets off of that, one or both of them usually loses a portion of their work, because this conflict is difficult or at least needlessly disruptive to manually merge. ProposalWere there basically a heuristic (i.e. deterministic first UID for any given file) that ensures that the same initial "new" file gets the same UID, merges and corrections in evil twin conflict cases are much less disruptive, since the .uid files will be identical, and are thus interchangeable. This is by far the most common case:
|
dotresbug.mp4Am I testing this wrong? |
No, that looks like a bug. Does |
I can't reproduce this. Open a new issue with a minimal project. |
I figured it out! It looks like the reference update is not retroactive to .res files. As a workaround I made a plugin that does that automatically to every .res in the project, if anyone is in need https://drive.google.com/file/d/1wpAQRoI5TxulDXekcgkADf0YdYureV43/view?usp=sharing Make sure to have all your scenes closed. |
Should the signals in |
Depending on what users are doing with those signals, changing them may break existing plugins, so it's worth thinking about it carefully. |
|
The references are stored both as path and UID. You can see it in tscn files. There is no compatibility breakage. |
I don't see any documentation changes to go along with the code changes. How can I understand the tradeoffs (benefits/downsides) of this change, the ways I can use it and its limitations? I don't intend to come across as bitter, but as someone testing the developer releases, I find myself dealing with an influx of new files that clutter my file views, such as OS Explorer and VSCode. This clutters my workspace and disrupts my workflow, making it more difficult to locate the files I need. I can be persuaded the changes are good for me, but I don't understand how yet due to lack of details. |
For me it seems like a medicine that is worse than the disease itself |
I'm all for UID files since the alternative is a messy find-and-replace approach, but I really dislike that it produces extra files all over my project. They really need to be placed in a dedicated directory. If it's having the same filepath that matters, just recreate the relative path from the root project directory inside of a directory like Edit: Someone else opened a proposal regarding these concerns. |
The whole point of having the uid files at the same path is that users move both files at the same time |
But that doesn't explain why the filenames can't start with a period, so that they can optionally be hidden and not clutter up the view. Even if the uid file is always visible, that doesn't ensure that the user will remember to copy/move it along with its parent file. |
But it makes is trivial. Having it in a separate folder makes it cumbersome and difficult for new user to know they have to do it. |
I suggested that the name start with a ".", not place it in a separate folder. |
Sorry I lost the thread of who said what. In any case, the "." makes all uids bunch together at the top. The convenience of the current approach is that you can bulk select files and be sure the uids are selected as well |
As long as the onus is on the human user, there is absolutely no guarantee the user will move uid files where Godot intends them to be regardless of whether they're located in a separate folder or the same folder. There are a few misguided assumptions in the comments so far regarding how users will interact with uid files.
I do not want to be in the business of managing uid files manually when I move code files around period. The benefits of the feature do not outweigh the introduced cost in my opinion. The system needs to handle it automatically. To reiterate my previous comment, I'd like to see documentation regarding how can I understand the tradeoffs (benefits/downsides) of this change, the ways I can use it and its limitations. |
Using a separate folder means you have to search for the corresponding .uid file if you want to move it. Yes, people might not know how to deal with .uid files as they are currently implemented, but it's still better and more intuitive solution than the other suggestions, especially when we already have .import files. Also, if you really don't want to deal with .uid files, just don't touch them and only move the base files. Obviously your dependencies will break, but it's the same thing we had before .uid files were introduced. The only thing that changes is that you'll get harmless warnings when doing so. |
As someone who disliked UID comments very strongly, I ended up with conclusion that if I have to choose between UID files zerg rush and UID comments/annotations inside scripts, comments/annotations are the lesser of two evils. |
I know comparisons are odious, but Unity's had this exact scheme for decades and it works. Most game devs have at least some degrees of familiarity with it and know the rules for dealing with metadata files. It's not the most elegant but it gets the job done and version control is really not an issue. I think you might be overreacting a bit here. |
I agree with @SpockBauru so far. Give me a choice in disabling this feature. I do not want to deal with the system's side effects, warnings, etc. I want to make games. Has the feature owner / Godot considered letting us generate a uid file on-demand for a specific file? Do we really need a uid for all files? As a user, if I have specific files I need uids for, then I could ask the system to generate a uid for them; in this model, I choose to create a dependency I'm willing to manage and understand how to seemingly. |
The UID files wouldn't be quite as bad if it didn't make one for every file that could potentially be a resource. I have 168 C# files in my project at the moment, and less than 30 of them are attached to a Node in the editor. The rest are libraries and whatnot yet they all have UID files generated for them as well. It should generate them once they are initially assigned to something in the editor, as needed, and automatically deleted when the last reference in the editor is removed. |
Just for reference, there's #99090. As I stated in #99090 (comment), UIDs for everything are desirable, but having a choice on how they are stored/managed would be great. |
Ensures all resource types support UIDs in a project. This is required to fix:
to be addressed in a subsequent PR, but this one effectively sets the prerequisites.
Resource types that do not support UID will get a .uid file appended to them (this includes .gd , .gdshader, .gdextension, etc files).
SCREENSHOT:
2D Platformer demo with uids auto generated:
(
Note RESOURCE.md, these are considered text resources by Godot and exported, so the .uid is actually correct.Edit: This was fixed before merging.)
TODO:
Editor refactoring not yet supported.De-duplication (if two UIDs are the same) not yet supported.FAQ:
Why not using metafiles instead to make it more generic?