Exporting to a drop down list

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By SawmillTurtle

I’m in the middle of a project that allows a lot of different options to be set using exported variables. It is my hope that the script, when completed, will be of use to others and will be usable with little to no scripting. What I’m attempting to do now is export an array or an enum as a drop down list from which the designer can select an option. I’ve looked through the documentation and I haven’t found anything that points me in the right direction. I’ve also looked through the list of available nodes, and only found “ItemList” under “Control”, which isn’t what I’m looking for.

Is this something that Godot is capable of? I’m wondering if there’s a hint I overlooked that does this. Something like:

export var (DROPDOWNHINT) myList = []

I even Googled the subject and found only questions about how to make a dropdown list as part of a UI. If someone could shed some light on this, I’d be extremely grateful to you.

:bust_in_silhouette: Reply From: Zylann

It is possible to export an “enumerated” value, which will look like a dropdown where you can select one option.
The syntax is shown here: GDScript exports — Godot Engine (stable) documentation in English

# Editor will enumerate as 0, 1 and 2.
export(int, "Warrior", "Magician", "Thief") var character_class
# Editor will enumerate with string names.
export(String, "Rebecca", "Mary", "Leah") var character_name

Exporting arrays is explained in the same page: GDScript exports — Godot Engine (stable) documentation in English

You know what’s really funny about this? About a minute or so after I posted this question, I stumbled upon the answer. With no way to delete my question, I felt really silly.

Thanks for your help.

SawmillTurtle | 2020-03-11 22:52

Better that it’s not deleted because, it’ll show up on search engines for people with the same question

AirWick | 2022-09-06 01:49

1 Like