I’ve been trying to implement a saving/load system into my game, and started by watching the live training archive video on data persistence. The video was very helpful and gave me the gist of:
- Creating a special class to hold the data that you want to save.
- Serializing this class.
- Deserializing this class.
- Applying all the data held in that class back to the game.
And, of course, this works very well for the demo, but is simply not practical in a game even slightly more complex, and this is where I’ve got some barriers that I’ve been struggling to get through. I could manually save all of my game’s important data, one variable at a time, but this is ludicrously laborious, and it’s all so hardcoded that it would be a pain to modify if anything about the game ever changed. (which, of course, is very likely to happen)
So, I’m curious. What are the better ways of doing this?
Is it possible for me to serialize, deserialize, and apply an entire monobehavior-derived class, such as one that might contain the player’s inventory? Or even better, what about entire game objects?
If not, is there a more dynamic way for me to store data in my special SavedData class? I imagine there might be, but that it would get complicated once I had to collect, store, and then apply that data to a bunch of different classes.
I’m just completely confused with all this, and it feels like there’s surprisingly limited documentation for this to be as literally essential to any game that it is.
Before I wrap this up, I do want to mention that I’m not opposed to 3rd party solutions, and I’m aware that there are a few of them, but I would like to understand what’s going on under the hood and, if possible, save some money by coding my own. I used Unity Serializer by whydoidoit but, besides it seeming like that excellent fella has been wiped from the face of the Earth, I don’t want to use a system that’s going to be incompatible with my game should I ever upgrade to Unity 5. (and that one apparently would be)
Thanks for taking the time to read and I hope you guys can give me some clear answers or point me in the right direction here.