A (better) UID handling proposal #11789
Replies: 2 comments
-
The downside with this approach is that if you move or rename the script, the path will be outdated even if its UID means the script can still be loaded. This can easily be misleading, especially if you have swapped around two scripts' paths. The editor would need to modify scripts on the user's behalf when moving files, even outside the editor, which sounds difficult to do. This can also mess with external editors especially on Windows due to file locking limitations. The best way to make your code easy to understand is to use explicit variable names when
There is no hard requirement in using UIDs: using |
Beta Was this translation helpful? Give feedback.
-
Yesterday I had a look at the Godot Editor source code. I think that a mixed approach uid cache + filenames with embedded uids could be a very good solution, especially considering there is a function in Godot code to recreate the cache from scratch.
I am sorry, but I don't 100% understand this sentence. In my scenario things go this way
When Godot starts:
Of course, but if you have:
and you created different versions of (about AI agents)
And this is good, but what if AI agents create new files inside the Godot Project? How is that handled? Yesterday I compiled Godot from sources, I was able to identify (and modify a bit ;-) the resource_uid.cpp file) and I created a small project to see how UIDs are handled, but in my project I didn't find any additional file for the uid (only the cache in the Thanks |
Beta Was this translation helpful? Give feedback.
-
I am looking at the new UID solution that should be shipped with Godot 4.4 and I am really worried it will produce a bigger impact than expected.
I read the article about why UIDs are so important and I completely agree with the article, but among the various approaches that devs have considered it seems that the solution I am going to introduce was missing.
Why the external file is problematic:
And this will kill code readability:
Furthermore, if in the future we want to use AI agents to create files for us, there could be a problem in automatically adding files into the file system.
My proposal is simple, yet effective: embed the UID inside the resource file name. Using 36 decimal notation, we can have rappresent 1.679.615 unique IDs with just 4 characters in the filename.
For eg. the
other_script.gd
could be calledother_script.x653.gd
, so the user could continue to write:when the resource name is parsed, internally Godot could just care for the
x653
part and load by UID and not by filename.Since with the external file solution the user should remember to move two files each time, he/she can also be instructed to just don’t touch the last part of a filename.
This is it, simple and effective.
I don’t know if I am posting in the right place, if not, please tell me and I’ll move the discussion in a more appropriate location.
Thanks for reading
Beta Was this translation helpful? Give feedback.
All reactions