- Home /
Scene saving
can you save a scene in game, so that when the game is restarted people still have everything that was added or removed in the scene?
Answer by TheCodeMonkey · Dec 05, 2011 at 02:31 PM
I am unsure if anything exists for this in unity itself. I believe it is up to you to save the "state" of everything in your scene if you wish to save that(something like buildings built, or what has been killed/completed so far) then depending on how your scene is structured when it starts it first checks for a valid savefile, and then builds itself accordingly. Although if that is the case it seems that you would have to build basically your entire scene to work with this system, things spawning/loading/appearing or not depending on what was in the save file information.
You should be able to use PlayerPrefs to get the job done:
http://unity3d.com/support/documentation/ScriptReference/PlayerPrefs.html
No, but there are third party plugins that serialize most of the scene. I don't know if Unity have fixed some issues with some variables not being public/usable for serialization... But at least in the past there have existed built in components that simply weren't loadable/savable, because you couldn't read or write some of the variables via code.
Answer by Statement · Dec 05, 2011 at 03:10 PM
Check out Above and Beyond Softwares EZ Game Saver which seems to be a quick and easy route for handling savegames. The task of writing your own save game code can be a daunting task unless you're familiar with reflection.
Also, depending on your code design, you might have to rethink a lot of your existing code to work with savegames. Every single data value has to be accounted for if you want to make an exact replica of the game state. For advanced games, adding savegames late on can be a challange.
Ahh I was unaware of that, thanks for sharing. Although it does look like either way Chesley will have to rework his code to account for the fact that it is a save game.
Answer by Ben-BearFish · Aug 24, 2014 at 04:47 AM
I know this is an old question, but for anyone new who sees this page, you should really look into Serialization/Deserialization. Especially using JSON. If you want an excellent plugin that does this for you, you should use this plugin:
http://forum.unity3d.com/threads/released-json-net-for-unity-3-5-with-aot-support.200336/
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Save data from one scene to another? 0 Answers
How to create a complicated game over scenario ? HELP 0 Answers
Create and Name a new scene through the script. 1 Answer
in-game programming console(how to?) 1 Answer