create unlock code for games unity code example
Example: how to use codes to unlock games unity
using UnityEngine; using System.Collections; public class Test : MonoBehaviour { public string levelCode; public bool isBlank; public bool isWrongKey; void OnGUI() { levelCode = GUI.TextField(new Rect(100, 100, 250, 30), levelCode); GUI.Label(new Rect(200, 60, 300, 40), "Enter Level"); if (GUI.Button(new Rect(100, 140, 250, 30), "OK!")) { GetInput(levelCode); } if(isBlank) { GUI.Label(new Rect(200, 200, 300, 40), "Invalid Key!"); } if(isWrongKey) { GUI.Label(new Rect(200, 200, 300, 40), "Wrong Key!"); } } public void GetInput (string guess) { if ((guess == "pass122") ||(guess == "pass133")) { Application.LoadLevel("Eat"); isBlank = false; isWrongKey = false; //Debug.Log("Load level Eat"); } else if (guess == "") { isBlank = true; isWrongKey = false; Debug.Log("Invalid Key!"); } else { isWrongKey = true; isBlank = false; Debug.Log("Wrong Key!"); } } }