The framework currently supports the saving and loading of games into game slots. The system currently support the following:

Saving the state of objects

All significant objects in the framework have been set up to save their state when the game is saved.

In order to achieve this, objects hold a SavableObjectState component and a ObjectUniqueId.

Untitled

By using the SavableObjectState component, the object transform, activation state (active or not active) and some extra information from specific components will get saved automatically.

Saving the state of components

In order for SavableObjectState to store extra information from components, the component will need to implement the ISavableObjectStateExtra interface, which will force you to implement two functions for serialization and deserialization of data as a string.

It’s up to the programmer to decide how to serialize this content. Data can be simply converted into a string for simple objects or, for more complex data, serialized into JSON and converted into a string.

Some components in the project are already setup to serialize its content: Health and DoorLock, which is why player and enemy health are persistent when loading and saving.

Object Unique Ids

Unique Ids are used to identity the object when serializing and deserializing the saved data.

The system automatically assigns unique Ids to prefab instances when dropped in the level, but conflicts might arise if an object is duplicated in the level, in which case you will get an error similar to the one below.

Untitled

This means you’ll have to resolve this conflict manually by assigning a new Id to one of the objects. You can do this by pressing the option “Regenerate Id” available in the ObjectUniqueId’s context menu.

Untitled