Search code examples
c#unity-game-enginescenescene-manager

Saving all scene content through script


I've been working on a game, and one of its features is being able to create a level. However, I'm having some trouble on how to save the level the user has created.

I'm thinking of duplicating the scene the player is working on when they hit the "save" button and then storing the scene somewhere where the user can access it later. I've tried a couple things, but to no avail.

It would be helpful if you could either:

  • Find a way to duplicate the scene
  • Find a way to save the scene without duplicating it

All help is appreciated!


Solution

  • Unfortunately, there is no way for developers to serialize anything that is in UnityEngine namespace. You can't save and then load e.g. GameObject, so you must make your own mechanism of saving the serializable data and loading a scene from the save.

    I m not sure what you are trying to save, but as a start, try using BinaryFormatter. IMO, it's very easy, fast and straightforward to use.