Save data while moving between scenes

Hi guys, so I’ve been developing this 3d game for a while and I had an idea to be able to play a 2d inside the actual 3d game. Let’s say you walk up to an arcade, it says Press E to play and the scene changes to the next one which is the 2d game.

I’ve managed to link all the scenes together but when the 2d game is over and the player comes back to the actual 3d game, the progress is lost.

Now I read about the DontDestroy thing (and please excuse my noobness here), I do not get how it works.

Can someone please help me understand how to save the 3d game while the scene changes to the 2d game so when the 2d game finishes, the 3d game starts from where it left off.

Depending on the complexity of the scenes involved, the simplest thing to may be to simply not unload your 3D scene at all.

You can use Additive scene loading to load the 2D minigame without unloading your main game scene, and just unload the minigame when it is done.

As long as you properly manage player input and UI, you should be able to return to your main game with minimal fuss.

2 Likes

Thank you for the quick answer! I’m still somewhat exploring Unity so for now, I found an easy workaround. setActive(false) the map objects while the 2D game is running and once it’s over, setActive(false) the game and do the opposite for the 3D map objects. Works like a charm.

1 Like

This is an excellent strategy for swapping all kinds of stuff in and out of a Unity scene. It simplifies so many problems to do things this way.

1 Like