Hello everyone, i am kinda trapped in a script here. I wanted to make an easter egg thing in my game. Something like if the player types TILT in sequence ( “T” then “I” then “L” then “T”) the game would change to another scene. I have a script here that a friend helped me to do, and it does what i want. At least the most… It loads a specific scene when i type TILT, but ONLY in something like a command chat. I wanted to remove that feature, and add just type. You know, nothing like click on the command chat and then type TILT, i wanted the player just to type TILT whenever he wanted in whatever place.
Here’s the script: (It’s a little complicated)
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using System.Collections;
public class LoadLevelCheatCode : MonoBehaviour
{
public string cheatcode = "tilt";
public void SubmitCode()
{
if (!GetComponent<InputField>()) {
Debug.LogError("Code wasn't typed correctly");
return;
}
string code = GetComponent<InputField>().text;
//This will try to see if you typed in "tilt" in game. If you do (and you press enter or exit the input field),
//it will try to load a level called cheatcode, which is a variable
//If it doesn't find a scene called cheatcode, we should see an error
if (code.Equals("tilt")) SceneManager.LoadScene(cheatcode);
}
}