- Home /
Android back button with pause game issue
Hi, I have added Android back button event on my game, when I press android back button game will pause, then I press again game will resume. But, used this feature in Update function. If I hold back button, game will pause-resume-pause-resume so on. How can I control this? I think I used flag but how?
Answer by nsejosh · Oct 29, 2014 at 11:07 PM
to check if the back button has been pushed in your update function, use
if( Input.GetKeyDown( KeyCode.Escape ) )
{
HandleBackPressed();
}
This will be true only on the frame on which the back button is pushed. it won't be true again until the user lets go of the back button and pushes it again. that way, holding it down won't cause a repeat. This works for all keys, not just the back button
Answer by Yury-Habets · Oct 30, 2014 at 02:22 PM
Just FYI - this is not a recommended behavior. According to Google design recommendations for Android TV (and will probably apply for all Androids), back button should navigate you back and be able to bring you to the home screen, not back and forth.
Just a thing to consider ;)
Answer by djokan231 · Jan 21, 2021 at 08:53 PM
Xb,Okay android back button is escape but volume button is what?
Your answer
Follow this Question
Related Questions
Unity backbutton crashes while on first scene 0 Answers
pause and restart button on android 1 Answer
End/Pause Game! 2 Answers
Pause Button Menu loader 2 Answers