Give Page Feedback | API

Upgrading - Player Prefs Persistent Data Controllers

Persistent Data Controllers are no longer used within the Streamable Assets Manager, as a new save/load system has been introduced that offers a greater amount of flexibility. This new system is based on the IPersistentStateManager interface, which is a new interface you can implement to comply with the save/load requirements of the Streamable Assets Manager. Alternatively, you can use the provided Binary Serializer Persistent State Manager, which provides an implementation of the IPersistentStateManager interface using binary serialization (a binary reader/writer to be more specific).

The intent behind the IPersistentStateManager interface is to allow you to integrate the save/load requirements of SAM into your existing save/load solution while also eliminating garbage generation for save operations.

With that said, if you have already deployed a Game using a Player Prefs Persistent Data Controller, or for any other reason need to be able to load data saved using a Player Prefs Persistent Data Controller, we have you covered! The data saved using the PlayerPrefsPersistentDataController class can be converted into the new Persistent State Manager format, however you will still need to create new Player Prefs Persistent Data Controller classes for each of your custom Player Prefs Persistent Data Controllers, under the new DeepSpaceLabs.SAM namespace.

Once you finish creating new Player Prefs Persistent Data Controllers using the information found in this Section, you can convert your old save data using the ComponentManager's static ConvertOldSavedata method. More information about using this method can be found in the Saving And Loading Data Section within the Component Managers Chapter, however we recommend completing this Section and conversion of your old Player Prefs Persistent Data Controllers before moving onto converting your old data.

Converting Old Save Data

--Special Note--
It is recommended to create new Player Prefs Persistent Data Controller classes rather than modifying your existing classes. This will ensure you can still access the data from existing components and can save them in case something goes wrong with the upgraded classes.

Creating A Player Prefs Persistent Data Controller Component

You can add this component by selecting a game object and then selecting from the Top Menu Bar:

Component -> Deep Space Labs -> -> SAM -> Deprecated -> Player Prefs Persistent Data Controller

Adding A Player Prefs Persistent Data Controller Component From The Top Menu Bar GIF

or by selecting a game object and using the Add Component menu via its inspector:

Component -> Deep Space Labs -> -> SAM -> Deprecated -> Player Prefs Persistent Data Controller

Adding A Player Prefs Persistent Data Controller Component From Add Component Menu GIF

One Small Change

Because this component is not generally used by SAM, it's make up is exactly the same as before. As such, you can simply copy all settings from your old Player Prefs Persistent Data Controller's to your new Player Prefs Persistent Data Controllers.

Using The Controller

In order to load data with the Player Prefs Persistent Data Controller, it's necessary to manually convert the data using the ConvertOldSaveData method of the Component Manager, specifically the method that has a PersistentDataController parameter.

--Special Note--
Conversion only needs to happen once for each save data, so after a successful conversion you should delete the old data. Use the ComponentManager.DoesOldPersistentDataControllerDataExist method to determine if data exist that needs to be converted.

Next Steps

Once you have your Controller setup and a mechanism in place for converting its data, we invite you to explore the new Persistent State Manager save/load solution to understand how the replacement for the Controller will work.

Persistent State Managers