Open videlanicolas opened 1 month ago
In your particular case, you can also use Vector2i(int("1920x1080".split("x")[0]), int("1920x1080".split("x")[1]))
to get a Vector2i from the resolution string. You don't need to add metadata this way.
Metadata is Variant, so https://github.com/godotengine/godot/pull/89324 is required for this feature.
In your particular case, you can also use
Vector2i(int("1920x1080".split("x")[0]), int("1920x1080".split("x")[1]))
to get a Vector2i from the resolution string. You don't need to add metadata this way.
I could, yes, but it's a coincidence that the text and the metadata I need to use happens to match. If I needed an OptionMenu
where each item holds metadata entries that have information not included in the text then I would need a script to manually add the metadata for each item.
Describe the project you are working on
I'm making the options menu for my game where the player can choose the screen resolution. I made an
OptionButton
Node and populated it with all the available resolutions:When the user selects a new screen resolution I resize the screen:
Describe the problem or limitation you are having in your project
I need to update an internal dictionary and update the OptionButton text each time I add a new resolution. Although it's rather infrequent, I think this can be better done with Metadata. Each item can have a metadata field with the
Vector2i
that corresponds to the resolution the user picked.But I can't set the metadata per item on the editor, I can only do so via a script.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
The editor should allow adding metadata fields for each item. That way I don't need to set the metadata through a script.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Add a button
+ Add Metadata
for each item onOptionButton
for the Editor. This should trigger aPopupMenu
with aTextEdit
and anOptionButton
to select the appropiate metadata. That is then added to the Item and the user can modify its value. The user can map 0 or more metadata fields per item.If this enhancement will not be used often, can it be worked around with a few lines of script?
Yes, one can:
_ready()
.OptionButton
and export a "metadata_per_item`Array
that collects metadata for each index of the items.Is there a reason why this should be core and not an add-on in the asset library?
The function to set the metadata is there, but it doesn't allow to do that on the Editor. This should be doable through the Editor as well.