-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
Add export_resource_uid annotation #91815
Conversation
ee54c26
to
194ac38
Compare
in my point of view |
I had considered that name, went with the longer one because it gives a "use me sparingly" feeling and I don't know if other uid might be used in future. |
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 you could use @export_custom(PROPERTY_HINT_RESOURCE_UID, "Type")
instead of @export_resource_uid("Type")
. You could also add a test, see export_variable.gd.
194ac38
to
997ed43
Compare
Can this annotation also be used with String type? I think UIDs as String are more common, and it will be easier to use in code (no need to ResourceUID.get_id_path) |
My dumb c++ brain shrieks "wasteful!" at an extra string allocation/conversion, but what do the maintainers think? @Calinou @AThousandShips |
The allocation isn't necessarily an issue, but if we use a So I'm unsure either way here, having just a convenient way to fetch the path as an UID instead of a file path is useful, but I'm not sure it warrants a whole new property hint Also we could have this hint support both |
997ed43
to
8444f0e
Compare
After reading that issue, it seems UID in general is half-baked? In that thread people are saying "use both" which entirely defeats the purpose of it right? I wanted this feature because |
Not really IMO, UIDs are safe generally, but there are contexts where they might be reset, they shouldn't but they might be, and being able to fall back on the other path is very useful and powerful, it can be trusted generally, but both together is the best |
That's good at least. About making this a "fully baked" solution, it's not possible. Not without rewriting large sections of core/io. |
As i saw the default custom export with the PROPERTY_HINT_RESOURCE_UID does not support creating arrays of UIDs, and it could still be convenient to have a "discoverable" way of doing that, since some hints are a bit hidden by the code suggestion menu |
Resource UIDs can now be selected from the inspector in the same way a Resource would be selected. EditorResourcePicker has new path_only property that hides menu items unrelated to UID selection.
8444f0e
to
81b0860
Compare
We're in feature freeze so this might have to wait for 4.4 |
Why draft? |
I think it can be further improved. I'll fix the conflicts and update it when I'm confident I can get it merged. |
Resource Path
Now available in asset library New improved syntax @export_file("PackedScene")
var some_scene: String Future Changes
|
I think this should be native in the engine. There is no built in way to do that, like Unity has with assets. This could lead to load every resource with the scene initialization and might cause reference cycles, something that cannot be handled natively. Making a plugin is fine, but it might be #difficult to discover, especially for beginners (which i think is the main target of Godot) |
This was effectively implemented by #97912 |
It's partially implemented. This is encouraging enough that I'm considering making the plugin an engine feature. |
Resource UIDs can now be selected from the inspector in the same way a Resource would be selected.
EditorResourcePicker has new path_only property to facilitate the annotation that hides menu items unrelated to UID selection.
Example usage:
Closes godotengine/godot-proposals#9216
Closes godotengine/godot-proposals#9552