- Home /
Back button
Creating a guide app for android. Im wondering how i would go about making a skript for the back button to the main menu.
Answer by efeguclu · Jul 04, 2017 at 02:15 PM
You should create a button, Rename Your Main Menu as MainMenu And attach it to build settings then create a script and paste this inside it :
public void BackButton(){
UnityEngine.SceneManagement.SceneManager.LoadScene("MainMenu");
}
then select button and open the inspector you'll see a button(plus) below onclick click on that then attach the script to the canvas and drag canvas inside the button onclick's object Select you script end select BackButton()
Thank you. I mainly just needed the skript to do it. I know how to do all the button config and gamw object
Can someone please elaborate on how to accomplish the following?
If Back Button Pressed
Scene$$anonymous$$anager.LoadScene("Start$$anonymous$$enu")
I cannot figure it out.
I tried
public void Update()
{
if (Application.platform == RuntimePlatform.Android)
{
if (Input.Get$$anonymous$$eyUp($$anonymous$$eyCode.Escape))
{
Scene$$anonymous$$anager.LoadScene("Start$$anonymous$$enu");
//quit application on return button
//Application.Quit();
return;
}
}
}
[SOLVED] This code works just fine in the Build, but does not working in the Unity Editor. One must Build and Install on an Android Device and run the game outside the Editor in order to see the effects.
Answer by Bunny83 · Jul 04, 2017 at 03:30 AM
Just check for the "escape" key:
void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
// do something.
}
}
If you would have searched before posting the question you should have found tons of similar examples.
Even when only searching here on UA you get endless results
There is no escape key an android and i did search around for this, dont be rude.
Your answer
Follow this Question
Related Questions
Reloading Scene - Android/Quest 1 Answer
Change Scene by Drag 0 Answers
App crashes after launching scene with AR Core for second time. 1 Answer
Android device Back button not going back to last scene 2 Answers
unity 4.6 input, missing touches 0 Answers