- Home /
Get Enum member from int
I have an enum called : Actions and it looks like :
public enum Actions { sleep = 1, food = 2, lookForFood = 3, lookForSleep = 4, wander = 5 };
My question is if there is a way to get the enum member from their int. Example:
Actions(1); // Return sleep
Comment
Best Answer
Answer by Dave-Carlile · Apr 29, 2013 at 11:20 PM
You can typecast the int...
Actions value = (Actions)1;
Correct. You can test that by Debug.Log(value.ToString());
Your answer
Follow this Question
Related Questions
Integer value casting to KeyCode enum in JS? 3 Answers
Why can't I animate an int or enum? 1 Answer
Can't compare byte to byte? 2 Answers
Set variable and then keep it that way 1 Answer
How to round or convert doubles? 2 Answers