Saving states on scene-change

Hi!

I want to change the scene and store changes made by the player (i.e. he opens a drawer) so when he returns to that scene the drawer is still open.

Another example:

  • player takes an inventory item, and leaves the scene. On return the item has to be gone.

Do I have to store these states in a database-like file or does Unity rebember these changes?

Thanks,
Oliver

Whenever you load a scene, it’s the same scene. For it to remember changes, you’ll need some sort of script that either saves the changes using PlayerPrefs.SetInt() or with a script that is told to DontDestroyOnLoad().

So, would could it be a good idea to save the the changes in a csv file, i.e. if I open the drawer in the scene then a would write something like this “drawer_open”;“1” to the file?

Next time I enter this scene I would load the file and all its states and set up the scene.

I don´t really want to stuff everything into the playerPref, because there will be hundreds of states in the game.