0 votes

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.

in Engine by (43 points)

1 Answer

+3 votes
Best answer

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: https://docs.godotengine.org/en/stable/getting_started/scripting/gdscript/gdscript_exports.html#examples

# 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: https://docs.godotengine.org/en/stable/getting_started/scripting/gdscript/gdscript_exports.html#exporting-arrays

by (27,766 points)
selected by

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.

How to reference exported string enum dropdown?
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.