Answer the question
In order to leave comments, you need to log in
Android Back button implementation in Unity3d?
Good day!)
Due to my inexperience in game development, I encountered the problem that in an application made on a unit by default, the android hardware buttons do not work -_-
I made the button itself how to track it.
using UnityEngine;
public class BackButton : MonoBehaviour {
void OnGUI()
{
if (Input.GetKeyUp(KeyCode.Escape))
{
Application.Quit();
}
}
}
Answer the question
In order to leave comments, you need to log in
try like this:
using UnityEngine;
public class BackButton : MonoBehaviour {
function Update ()
{
//if running on Android, check for Menu/Home and exit
if (Application.platform == RuntimePlatform.Android)
{
if (Input.GetKey(KeyCode.Home) || Input.GetKey(KeyCode.Escape) || Input.GetKey(KeyCode.Menu))
{
Application.Quit();
return;
}
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question