I have a scene where the player is able to slowly generate more content (like a sim builder), and I need this scene to save the instantiated prefabs for when he/she logs in or out.
The problem I am experience goes two ways, when I use the “don’t destroy on load” method the prefabs inter fear with my other scenes (obviously because they are not being destroyed).
So what I’m asking, am I supposed to save each objects position, and how many of that object here are, and re-instantiate each object every time the player reloads the scene? are there easier ways to do this? think about how mine craft keeps the position of all its blocks when the player logs out and back in? is there a way to save a whole scene and reload the whole scene as is or is it more complex?
Saving a scene is an editor function that will only work while running Unity. So you will need a different solution when it comes to deploying an app to any platform. I’d suggest writing data to either JSON or XML using the shortest fastest form possible. A database would work well too. Your scene then in Unity will just be the core elements and source prefabs. When your scene loads, the script will have to take care of instantiating all of the prefabs with the data saved previously. I also suggest starting with something really simple and test it on your target platform before getting too far building stuff in the editor.
If you want to save state between closing and reopening the application, PlayerPrefs is the way to go (or maybe PlayerSave, or even XML’s or databases). And yes, you’d have to save each thing you want, one by one (make it in the suggested array) and there’s no current easier way of doing it.
If, however, you’re having issues with DontDestroyOnLoad, conflicting objects, you have to review your scene & code and remove the conflicts one by one.
Hi. I made a long script with advanced load and save system.
Everything is about File stream. Every position, rotation and scale (basic datas of every object) are saved to txt file as a new Line.
You can save and load your instantiated objects. But first, if you want to load different meshes except Cube, you must create Resources folder in your assets project and duplicate meshes which will be loaded in a future.
Also you can set which objects will not be saved or loaded. You can edit script also, it is free and my without copy… Download here: [61586-save-load-system-v2.zip|61586]