Enjoy!
Code: Select all
using UnityEngine;
public class Cheats : MonoBehaviour
{
/// <summary>
///
/// </summary>
public string[] m_Code;
//Privates
private int index;
/// <summary>
///
/// </summary>
void Start()
{
//change this word for your code word
m_Code = new string[] { "y", "o", "u", "r", "c", "o", "d", "e"};//the example code is "yourcode".
//start index from
index = 0;
}
/// <summary>
///
/// </summary>
void Update()
{
//if no keypress is detected
if (!Input.anyKeyDown)
return;
//if the key is pressed with the same name of current char of cheat code...
if (Input.GetKeyDown(m_Code[index]))
{
index++;//continue with the next char
}
else
{
index = 0;//return to firts char
}
if (index == m_Code.Length)//is complete word
{
Debug.Log("Cheat unlocked!");
//Your Function here
//Example MorePower();
index = 0;//return to first char again (optional).
}
}
}