-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Script UID improvements #87418
Comments
Preloading with only a UID is less readable and inconsistent with other resources (it is assumed that UIDs can be safely removed/changed). I would expect an optional const Type = preload("res://script.gd", "uid://acdc") The same for extends "res://script.gd", "uid://acdc" Also note that you can use relative paths with extends "./script.gd"
const Type = preload("./other_script.gd") For |
This would also allow us to have a warning if the plain path is out of date, possibly with an option to update it in the editor |
No, the whole purpose of UID is that it's not supposed to change, unlike paths. The engine ensures that. Other resources already support load and preload, it only doesn't work for scripts. The readability can be always improved by adding a tooltip when hovering UID or even displaying it in a special way.
That's not any different from what we have now. When you change path, any script referencing it will break. Issuing a warning would require scanning every script on every path change and updating is useless unless it happens automatically. We could implement that even without UIDs. |
I meant with both uid and path, that specific suggestion |
This is only possible for the built-in editor. For external editors, GitHub, etc. this is less convenient (requires plugins or is not possible). When you see
Sometimes Godot changes UIDs for some reason, even if I didn't recreate the resource, but only edited/renamed/moved that resource or its dependencies. I think that in the current implementation this is also possible for GDScript, since the UID line is not only inserted when creating the So I wouldn't be sure that UID persistence is guaranteed. Also, as far as I understand, UID was not intended to be a replacement for file paths, only a secondary addressing system. All other resources store both file path and UID. The UID may be missing, but the path must be there. This is what I meant by inconsistency.
The difference is that if you encounter an incorrect file path (for example, if you got someone else's project), you can try to look for the components of the path in the file system, most often the file can be quickly found. If you encounter an incorrect UID that has no references left along with the file path, then it could be almost any script/resource (if you are not familiar with the project). |
I've been reading through the UID discussions/propositions/issues/PRs here this morning, and if I've understood correctly #97352 this has been moving in the direction where each script file gets its own .uid file where the UID is stored, and the editor handles renaming that .uid to match the name of the script file if the script file gets renamed.
So, just for this part I wanted to chime in that as I understand Unity has a similar system with its .meta files accompanying actual asset/script files and the UID within used for referencing, there have at least in my career repeatedly been cases where issues come up with "incorrect UIDs". Mainly goes something like this:
Depending on team sizes and skillsets there's multiple problems:
Pretty much all of this is manageable with experience and training, but I just wanted to note that having a broken project state with invalid UIDs as the only reference can be a bit of a frustration and may require some tinkering and sometimes just remaking entire assets (Node Trees) with broken references being the last remaining solution. This is not to say it's the wrong way to implement this, just that it's good to recognize any potential situations that may come with it. Thus I think the following point has merit, even if the additional human-readable filename(context) part is just the filename without path, only to help solve issues when they arise by providing context and the UID is used for actual references universally.
Also, do correct me if this is an unhelpful way to comment on development as I'm not really experienced in big open source projects at this point, so I'll know the etiquette a bit better in the future. |
As a former Unity Engine user, I want to add an additional, worse case when working with VCS:
|
Is it possible to use a .ignore file to determine which files and paths will not generate uid? |
I think this might've gone offtopic. The issue is about script UIDs. They were implemented, then reverted, now we have them again. This means scripts now have UIDs and are expected to work with UIDs everywhere where paths are supported (#99116 (comment)). I listed a few cases where they are not supported right now, and as per linked comment, they are expected to be resolved eventually. About UID design in general I think we should open a separate discussion.
Back on this, I think we can introduce some sort of local UID archive, where you can lookup what paths every UID pointed to. This could help in resolving conflicts/problems should they arrive.
Currently no, you can open a proposal. |
A local UID archive won't help if the bug was introduced by another developer. Especially if you are continuing development on an existing project. Also, I'd like to reiterate that UID is not human-readable and is not accessible (external IDEs without special plugins, on GitHub, viewing diffs, etc.). File paths and class names are primary identifiers, and UIDs are secondary. They should not be explicitly used by a human, in my opinion. I think we should either make UID an additional optional parameter to |
The other developer will also have an archive, which they can send to you if they can't fix the issue themselves. |
Tested versions
4.3
System information
Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1060 (NVIDIA; 30.0.15.1403) - Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (8 Threads)
Issue description
GDScript has a basic UID support now, but it has some missing features:
extends "uid://acdc"
)const Type = preload("uid://acdc")
)The first two result in an error currently, the last one does not exist (though you can copy UID using FileSystem context menu).
Steps to reproduce
Try using any of the above.
Minimal reproduction project (MRP)
N/A
The text was updated successfully, but these errors were encountered: