I have a canvas subclass to which I have added a property called Orientation. I have checked that class in Inspector Behavior and added an enumeration (Northeast = 0, Southeast = 1, …). However, I don’t seem to be able to refer to the enumeration constants in code. I’d really like to use a statement like “If Orientation = Northeast Then” but it appears that I can’t. Am I missing something, or are custom enumerations only half usable.
I usually create constants within my class for these values and name the enumerated inspector values the same (or at least similar). That’ll give you the functionality you want.
So, let’s say you have a border property for a class with the name “MyControl” with possible values of “BorderNone”, “BorderSingle”, and “BorderWide”. You’d add those as constants with values 0, 1, and 2 respectively and set them to public. Now, throughout your project, you can use “MyControl.BorderNone” to retrieve the value of that constant.
I don’t seem to be able to refer to enums declared in Inspector Behaviour, and conversely
enums created in the IDE can’t be referred to in Inspector Behaviour.
It’s like the 2 types of enum are mutually exclusive.
In my case, I have a container control that contains a large array of buttons that can be chosen by name in the program to form different button panels. Up until now I have given each button a string property to define its name throughout the program. I wanted to turn this into a better defined enum to make referencing easier and less error prone.
If I define an enumeration within the containerControl, I can make it the class of the buttonName property, but I can’t find a way of viewing this property within the Inspector Behaviour.
If I try the other way, and define the enum values of an integer property within Inspector Behaviour as custom values, then I can’t find a way of referring to those values elsewhere in the program.