Created
March 11, 2015 09:49
-
-
Save paulhayes/11daa42afd470c6bc75e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using UnityEngine.Events; | |
public class CheatCode : MonoBehaviour | |
{ | |
public string code; | |
public UnityEvent onCodeEntered; | |
protected int current; | |
void Update() | |
{ | |
if (Input.anyKeyDown) { | |
if (Input.GetKeyDown(code [current].ToString())) { | |
current++; | |
if (current >= code.Length) { | |
current = 0; | |
onCodeEntered.Invoke(); | |
} | |
} else { | |
current = 0; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment