- Home /
The question is answered, right answer was accepted
How to end a game with ESC button.
How to end a game with ESC button (quit the game and go back to windows after the player have finished playing)
Answer by Statement · Dec 03, 2009 at 04:14 PM
// JS function Update() { if (Input.GetKey(KeyCode.Escape)) { Application.Quit(); } }
// C# void Update() { if (Input.GetKey(KeyCode.Escape)) { Application.Quit(); } }
I could use this but where does one place this script? Does it go one the character controller camera or somewhere else?
I get an error saying "A namespace can only contain types and namespace declarations" @Statement
@kebabisdabest you have to put it in a Class - please see "Learn" atop the UA site and review C# scripting tutorials.
Answer by Eyeshine Studios · Mar 12, 2010 at 06:05 PM
How exactly does that work? Could you give an example? Do you create this in Java? Just cut and paste this over existing text and save?
Generally, it's better to add questions like that as a comment to the existing answer. But, to answer it - the code that @Statement wrote, would go in a script's Update() function. Second, it could be C# or Javascript, those two lines have nothing specific to either language.