Skip to content
This repository was archived by the owner on Jul 21, 2020. It is now read-only.

SGS The Save Game System

damagefilter edited this page Nov 23, 2016 · 3 revisions

What is it?

It's a system that lets you save and restore scene data to allow the implementation of a save game system.

How does it store game data?

It serializes data into bytes. The generated format is not human-readable. In the serialization pipeline we have ProtoBuf and the standard C# BinarySerializer, both working together to create save files. Future releases might see compressed bytes written to file too.

ProtoBuf? Do I need to create schemas now?

No. You can serialize anything that common sense implies is serializable without creating any schemas. There's no overhead in writing structure information or anything along these lines. The SGS is fully dynamic. It works based on attributes instead of relying on schema files.

Can I put in my own custom serializer into the pipeline?

No currently you can't but it's a feature I am looking at. However, since you can create your own ProtoContracts you are able to serialize also complex object trees easily.

What exactly can I save with this?

Anything, really. You can save the state of a whole scene or just some meta data. Any data that you might have, no matter how deep inside the scene structure it is can be saved and re-created when the scene is loaded again.

Conversely storing meta data, such as number of played levels, ranks, play time, current progression level etc is a easy thing to do and you needn't rely on PlayerPrefs.

What the SGS doesn't do

Data integrity.

As we will discuss at a later point, we can't save everything. For instance the invocation list of a delegate. It would be highly unreliable even if we would save it.

That means you'll have to think about these non-saveable pieces of your component and how to handle them after a save-game was loaded successfully. SGS provides events to listen to for several events such as post-load. You can hook into that if you want and need special post-processing. Keep that in mind and think about this from the beginning and you'll have solid save-games in no time.

I hope that will answer the most immediate questions.

Clone this wiki locally