I am trying to write numbers with a keypad and using a while loop to get the input from the user, every time I attempt to test it the game freezes .
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class TCLockNum : MonoBehaviour {
public Text Num;
private enum States {lock_1, lock_2};
private States myState;
public string num;
void Start () {
state_lock_1();
}
void Update () {
if (myState == States.lock_2) {
state_lock_2();
}
}
void state_lock_1 () {
while (num.Length<6) {
if (Input.GetKeyDown(KeyCode.Keypad1)) {
num=num+"1";
}else if (Input.GetKeyDown(KeyCode.Keypad2)) {
num=num+"2";
}else if (Input.GetKeyDown(KeyCode.Keypad3)) {
num=num+"3";
}else if (Input.GetKeyDown(KeyCode.Keypad4)) {
num=num+"4";
}else if (Input.GetKeyDown(KeyCode.Keypad5)) {
num=num+"5";
}else if (Input.GetKeyDown(KeyCode.Keypad6)) {
num=num+"6";
}else if (Input.GetKeyDown(KeyCode.Keypad7)) {
num=num+"7";
}else if (Input.GetKeyDown(KeyCode.Keypad8)) {
num=num+"8";
}else if (Input.GetKeyDown(KeyCode.Keypad9)) {
num=num+"9";
}else if (Input.GetKeyDown(KeyCode.Keypad0)) {
num=num+"0";
}
}
Num.text=num;
}
void state_lock_2 () {
}
}