Class BaseDataPersistence
Base persistence class derived from IDataPersistence
Inheritance
Namespace: UnityEngine.GameFoundation.DataPersistence
Syntax
public abstract class BaseDataPersistence : IDataPersistence
Constructors
BaseDataPersistence(IDataSerializer)
Declaration
public BaseDataPersistence(IDataSerializer serializer)
Parameters
| Type | Name | Description |
|---|---|---|
| IDataSerializer | serializer |
Fields
k_SaveVersion
Declaration
public static readonly int k_SaveVersion
Field Value
| Type | Description |
|---|---|
| System.Int32 |
Properties
serializer
The serialization layer used by the processes of this persistence.
Declaration
protected IDataSerializer serializer { get; }
Property Value
| Type | Description |
|---|---|
| IDataSerializer |
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 abstract 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 |
Implements
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 abstract 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 |