public abstract class PersistentDataController : MonoBehaviour
[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 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 Persistent Data Controllers (see
Upgrade
Chapter in SAM Editor Guide for more information).
Provides a base implementation for Persistent Data Controllers. These components control
how data is saved and loaded
between game sessions.
In order to utilize some of the inspector options (such as the ability to clear persistent
data) when creating your own class which derives from PersistentDataController, you
will need to create a custom inspector for your
custom class. Please follow the template in the EditorTemplates.txt file
(found in the "TerrainSlicing/OtherScripts/DynamicLoadingScripts/Editor" folder) when
creating this editor script.
Active Grid ID | int |
The ID of the Active Grid whose data should be cleared when the "Clear Data" button is pressed. This option is hidden with some Clear Methods. |
Clear All Persistent Scene Data | Button |
Clears all persistent scene data related to this Persistent Data Controller. This will effectively "reset" your scene and should be used with caution. |
Clear Data | Button |
Clears the persistent data in relation to the Current "Clear Method" and ID's. |
Clear Method | Dropdown |
The clear operation that will take place when the "Clear Data" button is pressed. Select a method and hover over it to see more information about it. |
Component Manager ID | int |
The ID of the Component Manager whose data should be cleared when the "Clear Data"
button is pressed. This option
is hidden with some Clear Methods.
|
Scene ID | string |
A unique string ID that identifies this Persistent Data Controller. The Component
Manager, which initiates all
persistent data saving/loading in SAM, automatically prepends this ID to every key
passed to the Persistent Data Controller. This allows
Component Manager's and Active Grids in different scenes to utilize the same ID.
|
Name | Type | Description |
---|---|---|
SceneID | string |
Gets the Scene ID of this Persistent Data Controller |
public abstract bool DoesDataExist(string key)
When overriden by a derived class, attempts to determine if data exist for the given key. This is used by the static ComponentManager.DoesOldPersistentDataControllerDataExist method to determine if data exist, which is useful for finding out if data needs to be converted to the new Persistent State Manager format using the static ComponentManager.ConvertOldSaveData method.
Name | Type | Description |
---|---|---|
key | string |
The key used to identify the data. |
bool
True if data exist, false otherwise.
public abstract void SaveData(string key, string data)
When overridden by a derived class, saves the specified data using the specified key.
Name | Type | Description |
---|---|---|
key | string |
The key used to save the persistent data. |
data | string |
The persistent data that will be saved. |
public abstract bool TryDeleteData(string key)
When overridden by a derived class, attempts to delete the persistent data associated with the specified key.
Name | Type | Description |
---|---|---|
key | string |
The key used to identify the persistent data that should be deleted. |
bool
A value indicating whether the persistent data was successfully deleted.
public abstract bool TryGetData(string key, out string data)
When overridden by a derived class, attempts to get the persistent data associated with the specified key.
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. |
bool
A value indicating whether the data was successfully retrieved. If false, "data" will
be null.