- Home /
Loop through values assigned to Enum var (using [Flags])
So I've got an enum (below) and I'm making a custom inspector for a script which has some PropFlags variables. The custom inspector uses an EnumMaskField to allow assigning multiple values to each var in the inspector. It works just fine, and I can use myPropFlags.HasFlag() or bitwise voodoo to check against one type at a time.
[Flags]
public enum PropFlags : int
{
Environment = 1,
Hazard = 2,
Agent = 4,
// and so on
}
I'd like to loop through each value assigned to myPropFlags (not each value in PropFlags, but each value assigned to a PropFlags variable). I've seen a few threads on ways of doing this, but the solutions look costly and none are things I know how to implement myself.
How should I do this? My amateurish instincts tell me to use a list or array of PropFlags and abandon the convenience of using EnumMaskField in the inspector. Given speed is far more crucial than convenience, what's my best option?
Thanks for reading!
Your answer
Follow this Question
Related Questions
Flag structure variable in unity editor 1 Answer
Custom PropertyDrawer to support the Flag is not change value. 0 Answers
hashtable: snapshot out of sync 2 Answers
Enum to int issue 1 Answer
GUI Enum Dropdown 2 Answers