Exposing enumerations to the editor
An enumeration is a user-defined data type that holds a list of integer constants, where each item has a human-friendly name assigned by you, which makes the code easier to read. As an example, if we wanted to represent the different states that a character can be in, we could use an integer variable where 0
means it’s idle, 1
means it’s walking, and so on. The problem with this approach is that when you see code such as if(State == 0)
, it’s hard to remember what 0
means unless you are using some type of documentation or comments to help you. To fix this problem, you should use enumerations, where you can write code such as if(State == EState::Idle)
, which is much more explicit and easier to understand.
In C++, you have two types of enums – the older raw enums and the new enum classes, which were introduced in C++11. If you want to use the new enum classes in the editor, your first instinct might be to do it in the...