Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
4
Question by blazk · May 30, 2014 at 07:40 PM · buttonmenuback

Back and Menu button on the device

Yo, so I am just wondering how to make a script for menu button and back button that are on the device? With this i mean this two buttons:

alt text

I know someone have used it so please share it with me, I would really need it :))) Thankssss

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

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by MikeNewall · May 30, 2014 at 07:45 PM

The "escape" key label appears to be

mapped to the back button on the android platform in the final release of Unity 3.0. As far as other mappings I've found that the "menu" key label is mapped to the menu key and that that MonoBehaviours will get an "OnApplicationPause" + true call when the home button is pressed and an "OnApplicationPause" + false when the application is brought back as the current process. I've not found a mapping for the search button as of yet. [http://answers.unity3d.com/questions/25535/android-back-button-event.html][1] [1]: http://answers.unity3d.com/questions/25535/android-back-button-event.html The search box is there for a reason... :p
Comment
Add comment · Show 3 · 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 blazk · May 30, 2014 at 08:25 PM 0
Share

Yes thanks so i will use that : if (Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.Escape)) { Application.Quit(); } But thanks anyway yes :) hope it will work :)

avatar image MikeNewall · May 30, 2014 at 09:34 PM 0
Share

Noticed that post is from a while ago. I'd be interested to know if they're still mapped to the same key codes.

avatar image blazk · May 30, 2014 at 09:46 PM 0
Share

Yes it worked i have tested it on android device and the code you see bellow works perfectlly fine for Back button (:

avatar image
4

Answer by alone1992 · Jan 30, 2015 at 09:20 AM

Hi dear You can use this codes for your work.

 function Update () {
  if (Input.GetKey(KeyCode.Home)){
  
  //Home button pressed! write every thing you want to do
  
  }
  if (Input.GetKey(KeyCode.Escape)){
  //Escape button codes
  }
  if(Input.GetKey(KeyCode.Menu)){
                 Application.Quit();
 }
 }
Comment
Add comment · Show 3 · 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 blastoformity7 · Dec 11, 2015 at 07:54 AM 0
Share

could you please tell me how to run the app in the background after the back button is pressed? thanks

avatar image siddharth3322 · Feb 17, 2018 at 03:52 PM 1
Share

Home or $$anonymous$$enu button key detection not working at all in current version of Unity. Any way exist to do this ?

avatar image max109y siddharth3322 · Nov 16, 2020 at 06:10 PM 0
Share

same for me only Escape button works

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

25 People are following this question.

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

Related Questions

Missing 'Options' in my GUI Menu? 2 Answers

Placing button at corner using NGUI 2 Answers

Unity UI How to make Multiple Clickable Next / Back Buttons? 3 Answers

iTween issue creating a gui. menu box 1 Answer

Back button issue: when I use back button to close keyboard, it also close the scene. 2 Answers


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