PlayerPrefsPersistentDataController Class

public sealed class PlayerPrefsPersistentDataController : PersistentDataController

[Deprecated] - Saving state via a Persistent Data Controller is no longer possible. Please use the new IPersistentStateManager interface instead. If you have old data saved with the player prefs persistent data controller that you absolutely need to make use of, you can convert the data using the ComponentManager.ConvertOldSaveData method. To do so, you will need to upgrade your Player Prefs Persistent Data Controllers (see Upgrade Chapter in SAM Editor Guide for more information).

Provides an implementation for a Persistent Data Controller that uses Unity's built in Player Prefs to save and load persistent data between game sessions.

Methods

DoesDataExist(string)

public sealed override bool DoesDataExist(string key)

Gets a value indicating whether data exist in PlayerPrefs for the given key.

Parameters

Name Type Description
key string

The key used to store the data.

Returns

bool
True if data exist, false otherwise.


SaveData(string, string)

public sealed override void SaveData(string key, string data)

Saves the specified data using the specified key in Player Prefs.

Parameters

Name Type Description
key string

The key used to save the persistent data.

data string

The persistent data that will be saved.


TryDeleteData(string)

public sealed override bool TryDeleteData(string key)

Attempts to to delete the persistent data associated with the specified key from Player Prefs.

Parameters

Name Type Description
key string

The key used to identify the persistent data that should be deleted.

Returns

bool
A value indicating whether the persistent data was successfully deleted.


TryGetData(string, out string)

public sealed override bool TryGetData(string key, out string data)

Attempts to get the persistent data associated with the specified key from Player Prefs.

Parameters

Name Type Description
key string

The key used to try and retrieve the persistent data.

data string

A string which will contain the data if successfully retrieved.

Returns

bool
A value indicating whether the data was successfully retrieved. If false, "data" will be null.