How do I make export item list variables

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


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>();

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

:bust_in_silhouette: Reply From: DDoop

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 = [

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?

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?

Unityfugee | 2021-01-25 23:54

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.

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

DDoop | 2021-01-26 00:03

It works, thanks!

Unityfugee | 2021-01-26 20:28