This chapter bloggers and everyone discuss how Unity implements similar Android native programs, and clicking the Android Back button enables you to return to the previous page.
1. Define a generic type to respond to the Android return button
Public Static list<GameObject> list;
Public Gameobject AddPanel; //Add Home Page
2, in the Start method will press the first page into the stack
List = new list<GameObject> (5);
//Press the page into the stack
List. ADD (AddPanel);
3, in the Update method in real-time monitoring the return button of the Android phone trigger situation
if (Input.getkeydown (Keycode.escape))
{
Androidback ();
}
4, from one page to another page to press the page name into the stack
Public Static void androidnext (gameobject Nextgo)
{
List. ADD (NEXTGO);
Nguitools.setactive (list[list. Count-2], false);
Nguitools.setactive (list[list. Count-1], true);
}
5. When you click the Back button on a page in an Android phone, the page name pops up on the stack.
Public Static void Androidback ()
{
if (list. Count > 1)
{
Nguitools.setactive (list[list. Count-1], false);
Nguitools.setactive (list[list. Count-2], true);
List. RemoveAt (list. COUNT-1);
}
Else
{
Application.loadlevel (0);
List. RemoveAt (0);
}
}
(Unity) Unity implements the ability to click the Android Back button to return to the previous page similar to the Android native project