i am android programmer and i want control button input in android for example i made a game that when you press back button in android mobile nothing happens but i want quite from game.
This is how you can use the android back button in Unity games.
In C#
void Update()
{
if (Application.platform == RuntimePlatform.Android)
{
if (Input.GetKeyDown(KeyCode.Escape))
Application.Quit();
}
}
or in JS
function Update()
{
if (Application.platform == RuntimePlatform.Android)
{
if (Input.GetKeyDown(KeyCode.Escape))
Application.Quit();
}
}
but how i can contorl other buttons
Answer
function Update () {
if (Input.GetKey(KeyCode.Home)){
// Home button pressed
// Write everything you want to do here
}
if (Input.GetKey(KeyCode.Escape)){
// Escape button pressed
}
if(Input.GetKey(KeyCode.Menu)){
Application.Quit();
}
}
No comments:
Post a Comment