How do you iterate values from variable that uses Enum Flags?
I tried using Enum Flags like this, but I dont know to get iteration of all values from variable that use the Enum Flags.
public class Tester : MonoBehaviour
{
[System.Flags]
public enum TestEnum
{
NONE = 0,
ALL = ~0,
option1 = 1 << 1,
option2 = 1 << 2,
option3 = 1 << 3
}
public TestEnum variable;
private void CheckEnum()
{
// I dont know how to iterate values from variable that use Enum Flags
foreach (var item in variable)
{
switch (item)
{
case TestEnum.option1: Debug.Log("Option 1");
break;
case TestEnum.option2: Debug.Log("Option 2");
break;
case TestEnum.option3: Debug.Log("Option 3");
break;
default:
break;
}
}
}
}