Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Sep 06, 2015 at 07:37 PM by getyour411 for the following reason:

The question is answered, right answer was accepted

avatar image
6
Question by user-297 (google) · Dec 03, 2009 at 03:47 PM · quitexit

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)

Comment
Comments Locked
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

  • Sort: 
avatar image
19
Best Answer

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(); } }

Comment
Comments Locked · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Michael 12 · Nov 26, 2011 at 10:59 PM 0
Share

I could use this but where does one place this script? Does it go one the character controller camera or somewhere else?

avatar image Statement · Dec 05, 2011 at 10:33 AM 0
Share

Anywhere...

avatar image kebabisdabest · Sep 06, 2015 at 07:21 PM 0
Share

I get an error saying "A namespace can only contain types and namespace declarations" @Statement

avatar image getyour411 · Sep 06, 2015 at 07:37 PM 0
Share

@kebabisdabest you have to put it in a Class - please see "Learn" atop the UA site and review C# scripting tutorials.

avatar image
0

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?

Comment
Comments Locked · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Cyclops · Mar 12, 2010 at 07:25 PM 0
Share

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.

avatar image Statement · Dec 11, 2010 at 09:49 AM 1
Share

Updated my answer.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity 5 - ExitApplication(); causes Crash 1 Answer

onExit, onQuit, or anything like that? 2 Answers

"Application" word in code not recognized. 1 Answer

Make a button quit the game, Unity 4.6 UI C# 1 Answer

Will Unity wait the method to finish before the application is closed/quit/stop? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges