I’m making save data for a game that I plan on updating a lot. There may be some save data information added and taken away over the upcoming months, so I wanted to make sure I had a way to update the game’s save data. I figured I would do this by adding an update code. If the update code in the game is higher then the one in the save data then it simply updates the information.
So the problem becomes how do add an update code to the save data separate from the main serialized data. If it unpacks all the data then it gets an error since stuff is missing. So I thought about adding a second class, so one would hold all the information and the other would hold the update code. That way I could take out just the update code, and if everything looks alright take out the rest. But… How do you do that?
This is the code I’m using right now to load information.
BinaryFormatter bf = new BinaryFormatter();
FileStream file = File.Open(Application.dataPath + "/SAVE/savedata.moewars", FileMode.Open);
FileData data = (FileData)bf.Deserialize(file);
file.Close();
Or maybe there’s a way to just unpack only the update code instead of unpacking all of it? That could maybe work if someone knows how to do that.