Class LocalPersistence
Namespace: UnityEngine.GameFoundation.DataPersistence
Syntax
public class LocalPersistence : BaseDataPersistence, IDataPersistence
Constructors
LocalPersistence(IDataSerializer)
Declaration
public LocalPersistence(IDataSerializer serializer)
Parameters
| Type | Name | Description |
|---|---|---|
| IDataSerializer | serializer |
Methods
Load<T>(String, Action<ISerializableData>, Action)
Asynchronously loads data from the persistence layer. Deserialized data, when loaded, are passed as second argument of the given onFinish Action. The generic param will be provided by the serializer underneath and need to implement ISerializableData
Declaration
public override void Load<T>(string identifier, Action<ISerializableData> onLoadCompleted = null, Action onLoadFailed = null)
where T : ISerializableData
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | identifier | Identifier of the persistence entry (filename, url, ...) |
| System.Action<ISerializableData> | onLoadCompleted | Called when the loading is completed with success |
| System.Action | onLoadFailed | Called when the loading failed |
Type Parameters
| Name | Description |
|---|---|
| T |
Overrides
Save(String, ISerializableData, Action, Action)
Asynchronously saves data onto the persistence layer. When the async save operation is done, onFinish Action get called.
Declaration
public override void Save(string identifier, ISerializableData content, Action onSaveCompleted = null, Action onSaveFailed = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | identifier | Identifier of the persistence entry (filename, url, ...) |
| ISerializableData | content | Data to persist (need to be serializable) |
| System.Action | onSaveCompleted | Called when the saving is completed with success |
| System.Action | onSaveFailed | Called when the loading failed |