How to go to previous scenes

Hi i’m new to unity and visual scripting and I’m making a little game.
I have a scene (scene 1)that will be accessed by other scenes (scene 2 and 3).

How can I make that when I’m in scene 1 and i press tge back bytton, I go to either scene 2 or 3 depending of which one led me to scene 1 ?

Here is what I’ve tried

-Unload a scene async (worked but I couldn’t interact with the previous scene).

-put the scene content into a game object and disabling it (the same result)

I tried to use enums but I don’t know how to do that with visual scripting.

Simple solution - save the last loaded scene’s index. It can be in Player Prefs or in a variable inside some script

1 Like

Can you explain to me how to do that ?

https://docs.unity3d.com/ScriptReference/PlayerPrefs.SetInt.html

This should help you. Whenever you load a scene save the current scene’s index under say “previousSceneIndex” key.

Then, on your back button method, you can get value that is under that key and open a scene with that index.

1 Like

Thank you very much

So i figured out another way.
i put it here for those who are strugling like me
All i had to do was load a scene additively by doing so the previous scene would still be active so i just had to tell that when i click on a button it “get active scene” then “get build index” and “load scene” from that build index.