Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Apr 15, 2016 at 01:36 PM by meat5000 for the following reason:

Duplicate Question

avatar image
0
Question by rakuzas · Dec 13, 2015 at 02:44 PM · androidbuttonquitdouble-tap

Press Back Button Twice to Quit Game

Hello,

I'm using unity 5.2 , Android Native plugin and run on Android platform..

Currently, I'm able to use script below to quit my game.. But some of my player complained that he always suddenly press back button and quit the game.. So, I notice some of apps press back button twice to quit their apps.. I tried to search some examples but just found some java not unity..

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

I tried to put like this (code below).. The toast message appear.. But its just quit the game without press second back button on my device..

 void Update () 
     {
         utilsPlugin = UtilsPlugin.GetInstance();
         utilsPlugin.SetDebug(0);
         
         QuitAndroid    ();
 }
 void QuitAndroid ()
     {
         if (Input.GetKeyDown (KeyCode.Escape)) 
             utilsPlugin.ShowToastMessage ("Press back again to quit");
             Application.Quit ();
 
             TapAgain ();
     }
 
 void TapAgain ()
     {
         if (Input.GetKeyDown(KeyCode.Escape)) 
             Application.Quit();
     }
 
Comment
Add comment · Show 2
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 meat5000 ♦ · Apr 15, 2016 at 09:18 AM 0
Share

http://answers.unity3d.com/questions/1115688/how-quit-the-game-only-after-pressing-back-button.html

avatar image meat5000 ♦ · Apr 15, 2016 at 09:19 AM 0
Share

http://docs.unity3d.com/ScriptReference/Input-backButtonLeavesApp.html

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

how to hide this if button click 1 Answer

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

UI works in editor, but not on mobile device 1 Answer

UnityPlayer quit is killing both itself and the Android app 0 Answers

If-statement on GUI.Button won't work on Android 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