Class LocalPersistence
This saves data locally onto the user's device.
Inherited Members
Namespace: UnityEngine.GameFoundation.DefaultLayers.Persistence
Syntax
public class LocalPersistence : BaseDataPersistence, IDataPersistence
Constructors
LocalPersistence(String, IDataSerializer)
Initializes the local persistence with the given file path & serializer.
Declaration
public LocalPersistence(string filename, IDataSerializer serializer)
Parameters
Type | Name | Description |
---|---|---|
String | filename | The relative path from persistentDataPath to the save file. |
IDataSerializer | serializer | The data serializer to use. |
Fields
kBackupSuffix
Suffix used for the backup save file.
Declaration
public const string kBackupSuffix = "_backup"
Field Value
Type | Description |
---|---|
String |
Properties
filename
The relative path from persistentDataPath to the save file.
Declaration
public string filename { get; }
Property Value
Type | Description |
---|---|
String |
fullpath
The absolute path to the save file.
Declaration
public string fullpath { get; }
Property Value
Type | Description |
---|---|
String |
Methods
Delete(Action, Action<Exception>)
Asynchronously delete data from the persistence layer.
Declaration
public void Delete(Action onDeletionCompleted = null, Action<Exception> onDeletionFailed = null)
Parameters
Type | Name | Description |
---|---|---|
Action | onDeletionCompleted | Called when the deletion is completed with success. |
Action<Exception> | onDeletionFailed | Called with a detailed exception when the deletion failed. |
Load(Action<GameFoundationData>, Action<Exception>)
Asynchronously loads GameFoundation's data from the persistence layer.
Declaration
public override void Load(Action<GameFoundationData> onLoadCompleted = null, Action<Exception> onLoadFailed = null)
Parameters
Type | Name | Description |
---|---|---|
Action<GameFoundationData> | onLoadCompleted | Called with the loaded data when they have been successfully loaded. |
Action<Exception> | onLoadFailed | Called with a detailed exception when the loading failed. |
Overrides
Save(GameFoundationData, Action, Action<Exception>)
Asynchronously saves GameFoundation's data onto the persistence layer.
Declaration
public override void Save(GameFoundationData content, Action onSaveCompleted = null, Action<Exception> onSaveFailed = null)
Parameters
Type | Name | Description |
---|---|---|
GameFoundationData | content | GameFoundation's data to persist. |
Action | onSaveCompleted | Called when data have been successfully saved. |
Action<Exception> | onSaveFailed | Called with a detailed exception when the save failed. |