0 votes

Hello,

Ho do I create an export variable whose value I can select from multiple pesets in a dropdown menu?

In Unity it would look like this in code :

public List<var> list = new List<var>();
list.Add("a");
list.Add("b");

Is it possible in Godot? If so, how is it done?

Godot version v3.2.3.stable.official
in Engine by (71 points)

1 Answer

0 votes
Best answer

The magic word is Array not List for GDscript (your question is marked gdscript but you have C# code, are you using Mono?)

export(Array) var arr = [
    item1,
    item2
];

EDIT: I don't really understand what you mean by presets, do you want a dictionary of bools with the ability to turn some of them on/off in the Editor inspector?

by (674 points)
selected by

No, the code is an example of how it's done in Unity. I want to do the same thing in Godot in GDScript.

I want to be able to set the variable in the inspector with a dropdown menu containing custom options that map to an index. Is it possible in Godot?

I'm pretty sure I understand now, my apologies. It is possible (and I learned something finding this)! Here is where someone has asked about it before, with further links to the docs.

basically:
export(int, "option1", "option 2", "option 3") var my_custom_property

It works, thanks!

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.