How do you set an enum variable?

David Beers 4 years ago updated by Lazlo Bonin (Lead Developer) 4 years ago 6

I've tried several methods, but nothing seems to work.  I have an enum defined in a C# script that I am able to set up in the variables window (I have one set as an application variable), but I can find no way to set it with a node (I can get it no problem).  The set application variable node looks like it will work, but it needs an input  which I cannot find a way to set up.  I cannot seem to find any node that will bring up the enum and let me pick one of the choices set in the script.  (Note: I am able to choose in the variable window, so I know bolt can see it, though it is listed as List of Enum Name, instead of just Enum Name). 

Thank you for any help. :)

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

Just to add, I tried passing in a string with the name of the enum choice, but it changed the variable to a string type from the enum type in the variables window. 


At this moment, variables set and get are not inlined with a type. They take in a generic object. So what you have to do is set it with a literal and select it from the literal.


Thank you for the tip!  I searched through the list of all the literals and I finally found it.  Also was able to set the variable in the variables window to the right enum type too.  :)

I feel stupid, but I think my problem was I didn't build units before building the inspectors (or I just tried to update the units) even though I thought I had done so.  I recreated my steps with a new enum and got the literal to show up right away after building units then building inspectors.  Sorry to be a bother.

Ah right on, not bothering me  one bit. Glad to help. Good you worked it all out though.


To be clear here: types you add to your options are instantly available as variable types, but not instantly available as unit options (for example, literals). As you figured out, you have to regenerate the unit database for them to show.