Based on your example, let’s take a look at what each part of the Enumeration declarations do…
private enum States{lots of states};
This gives the compiler a handy list of possible states. Any States instance must be set to one of those possible states. (there is no State.undefined, unless you put that name in the list).
private States myState;
This says I have a variable of type States… its value must be one of the values inside States. Depending on the compiler’s behavior, this will get auto assigned to either the first element in the enumeration, or any random value… ideally, when you declare, you’ll want to say:
private States myState=States.cell;
This ensure’s it’s set to a starting position.
That’s why
Debug.Log(myState);
returns “cell”, because it was initialized. (If I remember correctly, Unity initializes all variables to 0, 0.0f, “”, NULL etc… cell is the 0th element of States). Good programming practice is to always initialize your variables, and not assume that your compiler will do it for you, because while Unity is friendly this way, not all programming languages are.
On to the States.cell/mirror/sheets, etc… The States in this part of the expression is the Qualifier… it says I’m choosing a State from States specifically. While there are many compilers who could accept the syntax:
private States myState=cell;
it is good coding practice to always qualify your state. Then when you’re reading the code a year from now, you know right away, that you’re choosing from one of the members of State.
Now… when you want to change the state later in the code (say… our prisoner is looking at the mirror, you would simply use
myState=State.mirror;