When running the game in Unity and pressing the S key to go to the sheets_0 state nothing happens. It displays the text for the cell state but does not update to the sheets_0 state. I added a line to output to the debug console if Unity detects the S key is pressed, which it does (see screenshot). but does not progress beyond that.
I am on Unity version 5.4 1f1.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class TextController : MonoBehaviour {
public Text text;
private enum States {Cell, mirror, cell_mirror, lock_0, lock_1, sheets_0, sheets_1, freedom}
private States MyStates;
// Use this for initialization
void Start () {
MyStates = States.Cell;
Debug.Log(MyStates);
}
// Update is called once per frame
void Update ()
{
if (MyStates == States.Cell) {
State_Cell ();
} else if (MyStates == States.sheets_0) {
state_sheets_0();
}
}
void State_Cell ()
{
text.text = "You are in your prison cell and you want to escape There are" +
" some dirty sheets and a mirror on the wall and the door " +
"is locked \n\n " +
"Press S to view Sheets, M to view Mirror, and L to view Lock";
if (Input.GetKeyDown (KeyCode.S)) {
Debug.Log("S Key Pressed");
MyStates = States.sheets_0;
}
}
void state_sheets_0 (){
text.text = "You are in your prison cell and you want to escape There are" +
" some dirty sheets and a mirror on the wall and the door " +
"is locked \n\n " +
"Press S to view Sheets, M to view Mirror, and L to view Lock";
if(Input.GetKeyDown(KeyCode.C)){
MyStates = States.Cell;
}
}
}