Need Help With Going from One Scene to Another and Then Back to Previous Scene

Hello everyone,

I am new to Unity and I am making a game that has 2 segments: An overworld segment and a side-scrolling segment. In the overworld segment you perform actions that will trigger the side scrolling segments. I know how to transition from the overworld segment scene to the side scroll segment scene, but I do not know how I would be able to revert back to the previous scene without starting from the very beginning of the level and retain any actions I did. For example, if in the overworld I need to hack into a terminal, I would go up to it, press the corresponding button(E), and then it loads the hacking segment. Once the hacking segment is done I would like to revert back to the previous scene at the terminal, not the beginning of the level with the terminal hacked. I do not know if my wording makes 100% sense to anyone, but I really need to know. Please ask any questions you would like.

A simple solution is to create a singleton script that holds all of your persistent data for your overworld scene and then pass it to the DontDestroyOnLoad method. This will keep that GameObject around when scenes transition.

You could set it up so before you transition to the sidescrolling scene you take a “snapshot” of the overworlds data and store it in that script.

When you transition back to the overworld use that data to set everything back to the way it was and place the player to his/her/it’s last position.

You could also look into serializing the state of your overworld with JSONUtility or the binaryformater.

https://unity3d.com/learn/tutorials/topics/scripting/persistence-saving-and-loading-data