Adding a simple Drop-down Field in the Inspector

Previously we had to set an ID for the Power Up in the Inspector, let’s see how we can create a simple Drop-down Field for our options by introducing an enum variable type that is restricted to a set of values.

Enum
Short for Enumeration, an Enum is a user-defined keyword that allows you to declare a set of named constants called Enumerators. Enumerators are set of names for values.
They restrict the values that the enum variable can take and are a constant rather than a number, increasing readability of the source code.

First we create a private variable of type Enum. To access it in the Inspector we declare it into a private member variable called ‘powerUp’ of type PowerUp.
Enumeration to Integer

One of its benefits is that it automatically stores a value for each constant we add.
Now we can remove the ‘_itemID’ variable we used at first and instead pass one of the enum constants as an integer inside our switch() method.
