CloudOnce v2.7.5
Unified Game Services API
CloudOnce.Internal.DataManager Class Reference

Stores and retrieves key-value pairs. Serializes and deserializes GameData to/from the cloud and the local disk. In case of conflicts it uses ConflictResolver to figure out what data to keep and what to discard. More...

Static Public Member Functions

static void InitDataManager ()
 Loads any stored local data as part of the initialization.
 
static void SetCurrencyValues (string key, Dictionary< string, CurrencyValue > currencyValues)
 Set values for a currency. More...
 
static void SetBool (string key, bool value, PersistenceType persistenceType)
 Used to set a bool that will be stored in the cloud. More...
 
static void SetInt (string key, int value, PersistenceType persistenceType)
 Used to set an int that will be stored in the cloud. More...
 
static void SetUInt (string key, uint value, PersistenceType persistenceType)
 Used to set a uint that will be stored in the cloud. More...
 
static void SetFloat (string key, float value, PersistenceType persistenceType)
 Used to set a float that will be stored in the cloud. More...
 
static void SetDouble (string key, double value, PersistenceType persistenceType)
 Used to set a double that will be stored in the cloud. More...
 
static void SetString (string key, string value, PersistenceType persistenceType)
 Used to set a string that will be stored in the cloud. PersistenceType.Latest will be used in case of data conflict. More...
 
static void SetLong (string key, long value, PersistenceType persistenceType)
 Used to set a long that will be stored in the cloud. More...
 
static void SetDateTime (string key, DateTime value, PersistenceType persistenceType)
 Used to set a DateTime that will be stored in the cloud. More...
 
static void SetDecimal (string key, decimal value, PersistenceType persistenceType)
 Used to set a decimal that will be stored in the cloud. More...
 
static Dictionary< string, CurrencyValueGetCurrencyValues (string key)
 Get values for a currency. More...
 
static bool GetBool (string key, bool defaultValue)
 Returns the value of a specified bool. More...
 
static int GetInt (string key, int defaultValue)
 Returns the value of a specified int. More...
 
static uint GetUInt (string key, uint defaultValue)
 Returns the value of a specified uint. More...
 
static float GetFloat (string key, float defaultValue)
 Returns the value of a specified float. More...
 
static double GetDouble (string key, double defaultValue)
 Returns the value of a specified double. More...
 
static string GetString (string key, string defaultValue)
 Returns the value of a specified string. More...
 
static long GetLong (string key, long defaultValue)
 Returns the value of a specified long. More...
 
static DateTime GetDateTime (string key, DateTime defaultValue)
 Returns the value of a specified DateTime. More...
 
static decimal GetDecimal (string key, decimal defaultValue)
 Returns the value of a specified decimal. More...
 
static void RefreshCloudValues ()
 Refreshes all the cloud preferences created by the user. Is used after merging the local data with data from the cloud.
 
static void ResetSyncableCurrency (string key)
 Will completely reset the specified SyncableCurrency. More...
 
static bool ResetCloudPref (string key)
 Resets a CloudPref to its default value. More...
 
static bool DeleteCloudPref (string key)
 Deletes a specific cloud variable from local cache and the cloud. More...
 
static string[] ResetAllData ()
 WARNING! Resets all cloud variables back to their default values both locally and in the cloud! Should only be used while developing, not in production builds. Values are not saved automatically after the reset, and will go back to previously saved values if the game is restarted before saving. More...
 
static void DeleteAllCloudVariables ()
 WARNING! Deletes all cloud variables both locally and in the cloud (if logged into a cloud save service)! Should only be used while developing, not in production builds.
 
static string[] ClearStowawayVariablesFromGameData ()
 Used after clearing cloud data, to make sure that unwanted variables don't get re-saved to the cloud.
 
static void SaveToDisk ()
 Goes through all the cloud preferences created by the user, and stores them all in PlayerPrefs as one serialized string.
 
static void LoadFromDisk ()
 Loads data stored in PlayerPrefs.
 
static string SerializeLocalData ()
 Used by cloud save providers to serialize the local GameData for storing it in the cloud. More...
 
static string[] MergeLocalDataWith (string otherData)
 Used by cloud save providers when GameData it downloaded from the cloud needs to be merged with the existing local GameData. More...
 
static string[] ReplaceLocalDataWith (string otherData)
 Only to be used when player has switched to a different account. More...
 
static string[] GetRandomKeysFromGameData ()
 This method is only for simulating OnNewCloudValues in the Unity editor. More...
 

Static Public Attributes

const string DevStringKey = "CloudOnceDevString"
 

Properties

static bool IsLocalDataDirty [get, set]
 Whether or not any of the local data has been changed since the last upload to the cloud.
 
static Dictionary< string, IPersistentCloudPrefs [get]
 Stores all the registered cloud preferences created by the user.
 

Detailed Description

Stores and retrieves key-value pairs. Serializes and deserializes GameData to/from the cloud and the local disk. In case of conflicts it uses ConflictResolver to figure out what data to keep and what to discard.

Member Function Documentation

◆ DeleteCloudPref()

static bool CloudOnce.Internal.DataManager.DeleteCloudPref ( string  key)
inlinestatic

Deletes a specific cloud variable from local cache and the cloud.

Parameters
keyThe unique identifier for the cloud variable you want to delete.
Returns
true if the cloud variable is found and deleted, false if the specified key doesn't exist.

◆ GetBool()

static bool CloudOnce.Internal.DataManager.GetBool ( string  key,
bool  defaultValue 
)
inlinestatic

Returns the value of a specified bool.

Parameters
keyThe unique identifier for the bool.
defaultValueValue to return if key does not exist.
Returns
The value of the specified bool.

◆ GetCurrencyValues()

static Dictionary< string, CurrencyValue > CloudOnce.Internal.DataManager.GetCurrencyValues ( string  key)
inlinestatic

Get values for a currency.

Parameters
keyThe ID for the currency. Is unique to a specific currency.
Returns
Dictionary containing device IDs and currency values for each.

◆ GetDateTime()

static DateTime CloudOnce.Internal.DataManager.GetDateTime ( string  key,
DateTime  defaultValue 
)
inlinestatic

Returns the value of a specified DateTime.

Parameters
keyThe unique identifier for the DateTime.
defaultValueValue to return if key does not exist.
Returns
The value of the specified DateTime.

◆ GetDecimal()

static decimal CloudOnce.Internal.DataManager.GetDecimal ( string  key,
decimal  defaultValue 
)
inlinestatic

Returns the value of a specified decimal.

Parameters
keyThe unique identifier for the decimal.
defaultValueValue to return if key does not exist.
Returns
The value of the specified decimal.

◆ GetDouble()

static double CloudOnce.Internal.DataManager.GetDouble ( string  key,
double  defaultValue 
)
inlinestatic

Returns the value of a specified double.

Parameters
keyThe unique identifier for the double.
defaultValueValue to return if key does not exist.
Returns
The value of the specified double.

◆ GetFloat()

static float CloudOnce.Internal.DataManager.GetFloat ( string  key,
float  defaultValue 
)
inlinestatic

Returns the value of a specified float.

Parameters
keyThe unique identifier for the float.
defaultValueValue to return if key does not exist.
Returns
The value of the specified float.

◆ GetInt()

static int CloudOnce.Internal.DataManager.GetInt ( string  key,
int  defaultValue 
)
inlinestatic

Returns the value of a specified int.

Parameters
keyThe unique identifier for the int.
defaultValueValue to return if key does not exist.
Returns
The value of the specified int.

◆ GetLong()

static long CloudOnce.Internal.DataManager.GetLong ( string  key,
long  defaultValue 
)
inlinestatic

Returns the value of a specified long.

Parameters
keyThe unique identifier for the long.
defaultValueValue to return if key does not exist.
Returns
The value of the specified long.

◆ GetRandomKeysFromGameData()

static string[] CloudOnce.Internal.DataManager.GetRandomKeysFromGameData ( )
inlinestatic

This method is only for simulating OnNewCloudValues in the Unity editor.

Returns
A random selection of keys from the local GameData.

◆ GetString()

static string CloudOnce.Internal.DataManager.GetString ( string  key,
string  defaultValue 
)
inlinestatic

Returns the value of a specified string.

Parameters
keyThe unique identifier for the string.
defaultValueValue to return if key does not exist.
Returns
The value of the specified string.

◆ GetUInt()

static uint CloudOnce.Internal.DataManager.GetUInt ( string  key,
uint  defaultValue 
)
inlinestatic

Returns the value of a specified uint.

Parameters
keyThe unique identifier for the uint.
defaultValueValue to return if key does not exist.
Returns
The value of the specified uint.

◆ MergeLocalDataWith()

static string[] CloudOnce.Internal.DataManager.MergeLocalDataWith ( string  otherData)
inlinestatic

Used by cloud save providers when GameData it downloaded from the cloud needs to be merged with the existing local GameData.

Parameters
otherDataGameData as a serialized string.
Returns
A string array of the changed keys. Will be empty if no data changed.

◆ ReplaceLocalDataWith()

static string[] CloudOnce.Internal.DataManager.ReplaceLocalDataWith ( string  otherData)
inlinestatic

Only to be used when player has switched to a different account.

Parameters
otherDataGameData as a serialized string.
Returns
A string array of all the keys. Will be empty if the new GameData has no values.

◆ ResetAllData()

static string[] CloudOnce.Internal.DataManager.ResetAllData ( )
inlinestatic

WARNING! Resets all cloud variables back to their default values both locally and in the cloud! Should only be used while developing, not in production builds. Values are not saved automatically after the reset, and will go back to previously saved values if the game is restarted before saving.

Returns
A list of all cloud variable keys from the local GameData.

◆ ResetCloudPref()

static bool CloudOnce.Internal.DataManager.ResetCloudPref ( string  key)
inlinestatic

Resets a CloudPref to its default value.

Returns
Whether or not the CloudPref was successfully reset.

◆ ResetSyncableCurrency()

static void CloudOnce.Internal.DataManager.ResetSyncableCurrency ( string  key)
inlinestatic

Will completely reset the specified SyncableCurrency.

Parameters
keyThe unique identifier for the SyncableCurrency you want to reset.

◆ SerializeLocalData()

static string CloudOnce.Internal.DataManager.SerializeLocalData ( )
inlinestatic

Used by cloud save providers to serialize the local GameData for storing it in the cloud.

Returns
The local GameData as a serialized string.

◆ SetBool()

static void CloudOnce.Internal.DataManager.SetBool ( string  key,
bool  value,
PersistenceType  persistenceType 
)
inlinestatic

Used to set a bool that will be stored in the cloud.

Parameters
keyMust be a unique identifier for this specific value.
valueThe value for this bool.
persistenceTypeThe persistence type to use in case of a data conflict (ignored if value has been set before).

◆ SetCurrencyValues()

static void CloudOnce.Internal.DataManager.SetCurrencyValues ( string  key,
Dictionary< string, CurrencyValue currencyValues 
)
inlinestatic

Set values for a currency.

Parameters
keyThe ID for the currency. Is unique to a specific currency.
currencyValuesDictionary containing device IDs and currency values for each.

◆ SetDateTime()

static void CloudOnce.Internal.DataManager.SetDateTime ( string  key,
DateTime  value,
PersistenceType  persistenceType 
)
inlinestatic

Used to set a DateTime that will be stored in the cloud.

Parameters
keyMust be a unique identifier for this specific value.
valueThe value for this DateTime.
persistenceTypeThe persistence type to use in case of a data conflict (ignored if value has been set before).

◆ SetDecimal()

static void CloudOnce.Internal.DataManager.SetDecimal ( string  key,
decimal  value,
PersistenceType  persistenceType 
)
inlinestatic

Used to set a decimal that will be stored in the cloud.

Parameters
keyMust be a unique identifier for this specific value.
valueThe value for this decimal.
persistenceTypeThe persistence type to use in case of a data conflict (ignored if value has been set before).

◆ SetDouble()

static void CloudOnce.Internal.DataManager.SetDouble ( string  key,
double  value,
PersistenceType  persistenceType 
)
inlinestatic

Used to set a double that will be stored in the cloud.

Parameters
keyMust be a unique identifier for this specific value.
valueThe value for this double.
persistenceTypeThe persistence type to use in case of a data conflict (ignored if value has been set before).

◆ SetFloat()

static void CloudOnce.Internal.DataManager.SetFloat ( string  key,
float  value,
PersistenceType  persistenceType 
)
inlinestatic

Used to set a float that will be stored in the cloud.

Parameters
keyMust be a unique identifier for this specific value.
valueThe value for this float.
persistenceTypeThe persistence type to use in case of a data conflict (ignored if value has been set before).

◆ SetInt()

static void CloudOnce.Internal.DataManager.SetInt ( string  key,
int  value,
PersistenceType  persistenceType 
)
inlinestatic

Used to set an int that will be stored in the cloud.

Parameters
keyMust be a unique identifier for this specific value.
valueThe value for this int.
persistenceTypeThe persistence type to use in case of a data conflict (ignored if value has been set before).

◆ SetLong()

static void CloudOnce.Internal.DataManager.SetLong ( string  key,
long  value,
PersistenceType  persistenceType 
)
inlinestatic

Used to set a long that will be stored in the cloud.

Parameters
keyMust be a unique identifier for this specific value.
valueThe value for this long.
persistenceTypeThe persistence type to use in case of a data conflict (ignored if value has been set before).

◆ SetString()

static void CloudOnce.Internal.DataManager.SetString ( string  key,
string  value,
PersistenceType  persistenceType 
)
inlinestatic

Used to set a string that will be stored in the cloud. PersistenceType.Latest will be used in case of data conflict.

Parameters
keyMust be a unique identifier for this specific value.
valueThe value for this string.
persistenceTypeThe persistence type to use in case of a data conflict (ignored if value has been set before).

◆ SetUInt()

static void CloudOnce.Internal.DataManager.SetUInt ( string  key,
uint  value,
PersistenceType  persistenceType 
)
inlinestatic

Used to set a uint that will be stored in the cloud.

Parameters
keyMust be a unique identifier for this specific value.
valueThe value for this uint.
persistenceTypeThe persistence type to use in case of a data conflict (ignored if value has been set before).

The documentation for this class was generated from the following file: