How can I create a unit that displays a dropdown choice

Real World 3 years ago updated by JasonJonesLASM 3 years ago 1

I've created a Unit subclass and a ValueInput is currently set to string. There are a limited number of valid options this string could be (the valid options are stored in an array). If my input type was an enum then I would see a drop down list. I'd like to do the same for this string/string array. Is that possible?

Bolt Version:
Unity Version:
Scripting Backend:
.NET Version (API Compatibility Level):

You'll need to create your own Inspector and Class that contains a string array. You'll need an empty property drawer (empty if not used with scriptable objects and monobehaviour), and a class that Inherits from Inspector with the class attribute Inspector as well There should be some Unity Editor stuff for dropdowns. Mark your drop down class as Inspectable to serialize with Bolt. You can then use it as an input, unit header, pretty much anywhere Bolt shows that class. You'l needl a persistent way to store these values in the Editor though.

Here is a header example of variables from a scriptable object carried over into a drop down for a header.