How to create a back button?
Hello! In Unity, i'm creating a game of multiple scenes and I'm trying to make a 'back button', to load the scene I was i last. So far I have to create individual scripts for each "goto" scene. Say I was to goto the inventory scene.
 public class Inventory : MonoBehaviour
 {
     public Button inventoryButton;
     // Start is called before the first frame update
     void Start()
     {
         Button btn = inventoryButton.GetComponent<Button>();
         btn.onClick.AddListener(TaskOnClick);
     }
 
     // Update is called once per frame
     void TaskOnClick()
     {
         SceneManager.LoadScene("Inventory");
     }
 }
 
               And then from there, in the inventory scene, I have 2 buttons. Primary Inventory and Secondary inventory.
 public class PrimaryInventory : MonoBehaviour
 {
 
     public Button yourButton;
     // Start is called before the first frame update
     void Start()
     {
         Button btn = yourButton.GetComponent<Button>();
         btn.onClick.AddListener(TaskOnClick);
     }
     void TaskOnClick()
     {
         SceneManager.LoadScene("PrimaryInventory");
     }
 }
 
               ^^^Load Primary Inventory Scene public class SecondaryInventory : MonoBehaviour {
     public Button yourButton;
     // Start is called before the first frame update
     void Start()
     {
         Button btn = yourButton.GetComponent<Button>();
         btn.onClick.AddListener(TaskOnClick);
     }
     void TaskOnClick()
     {
         SceneManager.LoadScene("SecondaryInventory");
     }
 }
 ^^^ Load Secondary Inventory Scene
 
               From here, (already have a ToMenu Script) I want to be able to go directly back into Inventory Scene without having to create another script.... Sorry if this was super confusing... Long story short, I just want a back button that will take me to the last scene visited... XD
               Comment
              
 
               
              Your answer