EDIT: Unity was just being dodgy or something. I opened it up this morning and there were no errors. Tested it, and it worked. Exact same script as before.
Escape button (not “buton”) doesn’t exist?
What I need is to have it so that pressing the “escape” button takes me to the Main Menu (index 0 in the build list). I have the script in an empty object, along with my working restart script. But apparently, escape isn’t a button. I’ve also tried “esc” and “Esc” and all that.
First I tried this (and various changes like removing the capital letter and putting it in quotes and stuff):
function Update ()
{
if (Input.GetKeyDown(KeyCode.Escape) {
Application.LoadLevel (0);
}
}
Then I tried this from Unity - Scripting API: Application.Quit and changed it to:
function Update ()
{
if (Input.GetKey ("escape")) {
Application.LoadLevel (0);
}
}
But it still came up with an error saying escape doesn’t exist, even with me making the same changes to it as the original script I made.
So I don’t have a clue what to do. Any ideas?