Step 1: Create scene and assets
First, we create the first scene and inside create a UI --> text object. It will ask a bunch of questions then we can say necessary import assets which I did.
That was the menu name so I put it in the centre
Similarly, i created a button and adjusted it
remember the text is a separate object
Here is what the button looks like
Step 2: Scripting
Here I selected the button
Then in the right panel I pressed add component.
Chose New script and named it NavigateMenu.cs
I deleted all the void stuff and added the following
make sure you add
using UnityEngine.SceneManagement;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class NavigateMenu : MonoBehaviour
{
public void SwitchScene(string sceneName)
{
SceneManager.LoadScene(sceneName);
}
}
Step 3: Activating Button
While having the button selected I pressed the "+" on the right panel to add a On Click() behviour
Then I added the button itself to the behaviour
Then I added NavigateMenu --> SwitchScene (String) to the function
Note: the Button will change to
Then I just typed in the name of the scene I wanted to go to
in this case "test
I then created another scene called "test" and followed the steps again to create a button to go back
Step 4: adding the scenes to a pool where unity can call them.
In File --> Build Settings
Make sure both scenes are added to the list