Wanzyee Studio
CryptoPrefs

Access UnityEngine.PlayerPrefs encrypted by specific device. More...

Static Public Member Functions

static bool HasKey (string key)
 Return true if key exists in the preferences. More...
 
static void DeleteKey (string key)
 Remove key and its corresponding value from the preferences. More...
 
static T GetValue< T > (string key, T defaultValue=default)
 Get the value of the specified preference key, return the defaultValue if doesn't exist. More...
 
static void SetValue< T > (string key, T value)
 Set the value of the specified preference key. More...
 

Detailed Description

Access UnityEngine.PlayerPrefs encrypted by specific device.

Member Function Documentation

static bool HasKey ( string  key)
static

Return true if key exists in the preferences.

Parameters
keyKey.
Returns
true if key exists.
static void DeleteKey ( string  key)
static

Remove key and its corresponding value from the preferences.

Parameters
keyKey.
static T GetValue< T > ( string  key,
defaultValue = default 
)
static

Get the value of the specified preference key, return the defaultValue if doesn't exist.

This uses StringExtension.MustTo() to convert the preference string to the value. And will delete the preference if error occurs when converting or decrypting.

Template Parameters
TThe value type.
Parameters
keyKey.
defaultValueDefault value.
Returns
The value.
static void SetValue< T > ( string  key,
value 
)
static

Set the value of the specified preference key.

This use the ToString() of the value to save, or delect the preference if null.

Template Parameters
TThe value type.
Parameters
keyKey.
valueValue.