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 /
avatar image
2
Question by homph · Mar 25, 2015 at 08:02 AM · uibuttonunity5quitexit

Make a UI button quit the exe, Unity 5

Hi,

I am fairly new to Scripting and Unity so please excuse my lack of knowledge !

I Have created a 'quit' button in the UI and a quit script which is attached to the 'quit' button. My quit script is as follows:

 #pragma strict
 
 import UnityEngine.UI;

 
 public function ClickExit () {
    
     Application.Quit();
     
 }

I use the OnClick()and select my ClickExit function, but it doesn't quit. I have added a debug function to print a text message which calls fine from the OnClick so I know the button is working. I have also created a build and it still doesn't quit. If someone could please help me with this that would be majic

Comment
Add comment · Show 3
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 CodeElemental · Mar 25, 2015 at 08:55 AM 0
Share

Application.Quit() is not working in the Editor. try making a build and run the build exe.

avatar image iceangel026 · Jun 13, 2015 at 07:58 PM 0
Share

it works fine... i use this for my android app... i think its an easy way to quit a game...

sorry for my bad english...

avatar image zolutr iceangel026 · Sep 22, 2016 at 06:04 PM 0
Share

maeby is a bit late but, it's better not to use this in android or IOS since the stores dont like people using the function Application.Quit(); and could take your app out of the store for this motive

2 Replies

· Add your reply
  • Sort: 
avatar image
5

Answer by AceScottie · Mar 26, 2015 at 11:09 AM

not sure it this will help but in my GUI i have it as a keydown event with an if statement

 if (Input.GetKeyDown(KeyCode.Escape)) {
     Application.Quit();
 }

you should try use an If statement

 public function ClickExit() {
     if (GUI.Button //your button here) {
         Application.Quit();
     }
 }

hope this helps but i also did mine using c# not js

Comment
Add comment · 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
0

Answer by homph · Apr 08, 2015 at 03:01 PM

Many thanks for your help. In the end I noticed that Unity wasn't updating my UI layout when I was creating a build, so I restarted my machine, Unity ! Created a new Canvas and the Quit button worked !

Comment
Add comment · Show 1 · 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 Hellium · Jun 13, 2015 at 08:03 PM 0
Share

Don't forget to mark your question as resolved by clicking on the check mark of your own answer ! ;)

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

7 People are following this question.

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

Related Questions

[5.4 - Unity2D - Android] UI Button Requires Child Text? 0 Answers

How to make a UI Canvas not appear again after the first time the user hits the "I Agree" button. 2 Answers

Unity 5: UI button OnPointerDown not function as expected 1 Answer

I can't click to an UI button. 3 Answers

Make a button quit the game, Unity 4.6 UI C# 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