LootLocker Unity SDK 8.2.0
Game backend SDK for Unity
Loading...
Searching...
No Matches
LootLocker.ILootLockerStateWriter Interface Reference

Implement this interface to create a custom persistent state writer for saving and loading player state data. More...

Inherited by LootLocker.LootLockerNullStateWriter, and LootLocker.LootLockerPlayerPrefsStateWriter.

Public Member Functions

string GetString (string key, string defaultValue="")
 Get a string from persistent storage.
 
void SetString (string key, string value)
 Set a string in persistent storage.
 
int GetInt (string key, int defaultValue=0)
 Get an int from persistent storage.
 
void SetInt (string key, int value)
 Set an integer in persistent storage.
 
void DeleteKey (string key)
 Delete a key from persistent storage.
 
bool HasKey (string key)
 Check if a key exists in persistent storage.
 

Detailed Description

Implement this interface to create a custom persistent state writer for saving and loading player state data.

The default implementation uses Unity's PlayerPrefs. If that is something you do not want then you can implement this interface and set your implementation using LootLockerSDKManager.SetStateWriter The requirements are:

  • The implementation can save and load strings to persistent storage that is retrievable across game sessions.
  • The implementation must be thread safe.
  • The implementation must be performant enough to not cause noticeable hitches in the game when saving or loading data.
  • The implementation must be able to consistently retrieve the data that was saved from the provided key

Member Function Documentation

◆ DeleteKey()

void LootLocker.ILootLockerStateWriter.DeleteKey ( string  key)

Delete a key from persistent storage.

Parameters
keyThe key to delete.

◆ GetInt()

int LootLocker.ILootLockerStateWriter.GetInt ( string  key,
int  defaultValue = 0 
)

Get an int from persistent storage.

If the key does not exist then return the provided default value.

Parameters
keyThe key to retrieve the value for.
defaultValueThe value to return if the key does not exist.
Returns
The value associated with the key, or the default value if the key does not exist.

◆ GetString()

string LootLocker.ILootLockerStateWriter.GetString ( string  key,
string  defaultValue = "" 
)

Get a string from persistent storage.

If the key does not exist then return the provided default value.

Parameters
keyThe key to retrieve the value for.
defaultValueThe value to return if the key does not exist.
Returns
The value associated with the key, or the default value if the key does not exist.

◆ HasKey()

bool LootLocker.ILootLockerStateWriter.HasKey ( string  key)

Check if a key exists in persistent storage.

Parameters
keyThe key to check for existence.
Returns
True if the key exists, false otherwise.

◆ SetInt()

void LootLocker.ILootLockerStateWriter.SetInt ( string  key,
int  value 
)

Set an integer in persistent storage.

Parameters
keyThe key to set the value for.
valueThe value to set.

◆ SetString()

void LootLocker.ILootLockerStateWriter.SetString ( string  key,
string  value 
)

Set a string in persistent storage.

Parameters
keyThe key to set the value for.
valueThe value to set.