How to access mobiles back button in unity for android applications

Shreenath M picture Shreenath M · Oct 9, 2016 · Viewed 7.9k times · Source

I am building a VR application with a menu scene and many other scenes.. I would like to get back into the menu scene from any other scene when the user hits the mobiles back button (android).. What is the script for that and where should i place the script??

Answer

Programmer picture Programmer · Oct 9, 2016

You use the Escape keycode to detect back button press on Android.

using UnityEngine.SceneManagement;

void Update()
{
    if (Input.GetKey(KeyCode.Escape))
    {
        SceneManager.LoadScene("Main Menu");
    }
}