MultikeyPrefHelper Class Reference

MultikeyPrefHelper provides convenience functions for checking, reading, storing and deleting Vector3, Vector2, Color, and Enums in Unity's preferences storage.

Detailed Description

The PrefInterfaceType type parameter defines weather operations are performed on Unity PlayerPrefs or EditorPrefs. Based on the type of value being written, multiple editor pref keys may be used (transparently) to store the whole value. Each key will use the same key name, but have an additional character appended to specify what component of the value it represents. For example, a Vector3 stored with the key "MyVec", will ACTUALLY (though transparently) be stored as 3 key/value pairs, "MyVecX","MyVecY","MyVecZ" It is the programmers responsibility to make sure the type of each key is used consistently.

  • the "Has" functions are used to determine if the specified key already exists in the editor preferences. Note: The has function only checks for the first component of the key, and returns true if found in Editors preferences. It does not check/confirm what type of data stored in the key.
  • the "Get functions are used to retrieve existing values from the editor preferences. If the specified key does not exist or is found stored as a different type, a default value , usually zero(s), will be returned.
  • the "Set" functions are used to store new values in the specified editor preference. No checking is performed on the key to confirm it's type. The specified key/value pair is added to editor preferences, if it does not already exist. If the key already exists in editor Preferences, it's value is updated.
  • the "Delete" functions also perform no checking: any preference using the key will simply be deleted.

Static Public Member Functions

static void DeleteBoolKey (this IStorePreferences interfaceReference, string key)
 Deletes the bool value associated with this key, in prefBase, to the provided bool value. Behind the scenes, the values are stored as an integer 0- false, 1-true
 
static void DeleteColorKey (this IStorePreferences interfaceReference, string key)
 Deletes the Color (RGBA) value associated with this key, and the key itself, from prefBase. Behind the scenes, the key-float pairs deleted are, key+"R", key+"G", key+"B" and key+"A".
 
static void DeleteVector2Key (this IStorePreferences interfaceReference, string key)
 Deletes the Vector2 value associated with this key, and the key itself, from prefBase. Behind the scenes, the key-float pairs deleted are, key+"X", and key+"Y".
 
static void DeleteVector3Key (this IStorePreferences interfaceReference, string key)
 Deletes the Vector3 value associated with this key, and the key itself, from prefBase. Behind the scenes, the key-float pairs deleted are, key+"X", key+"Y" and key+"Z".
 
static bool GetBool (this IStorePreferences interfaceReference, string key)
 Gets the bool value associated with this key, from prefBase. Behind the scenes, the values are stored as an integer 0- false, 1-true
 
static Color GetColor (this IStorePreferences interfaceReference, string key)
 Gets the Color (RGBA) value associated with this key, from prefBase. Behind the scenes, the values are stored as three key-float pairs, key+"R",key+"G", key+"B" and key+"A" in prefBase
 
static Vector2 GetVector2 (this IStorePreferences interfaceReference, string key)
 Gets the Vector2 value associated with this key, from prefBase. Behind the scenes, the values are stored as two key-float pairs, key+"X", and key+"Y" in prefBase
 
static Vector3 GetVector3 (this IStorePreferences interfaceReference, string key)
 Gets the Vector3 value associated with this key, from prefBase. Behind the scenes, the values are stored as three key-float pairs, key+"X", key+"Y" and key+"Z" in prefBase
 
static bool HasBoolKey (this IStorePreferences interfaceReference, string key)
 Check for the existence of key in prefBase
 
static bool HasColorKey (this IStorePreferences interfaceReference, string key)
 Check for the existence of key +"R" in prefBase
 
static bool HasVector2Key (this IStorePreferences interfaceReference, string key)
 Check for the existence of key +"X" in prefBase
 
static bool HasVector3Key (this IStorePreferences interfaceReference, string key)
 Check for the existence of key +"X" in prefBase
 
static void SetBool (this IStorePreferences interfaceReference, string key, bool value)
 Sets the bool value associated with this key, in prefBase, to the provided bool value. Behind the scenes, the values are stored as an integer 0- false, 1-true
 
static void SetColor (this IStorePreferences interfaceReference, string key, Color color)
 Sets the Color value associated with this key, in prefBase, to the provided Vector2. Behind the scenes, the values are stored as three key-float pairs, key+"R",key+"G", key+"B" and key+"A" in prefBase
 
static void SetVector2 (this IStorePreferences interfaceReference, string key, Vector2 vector)
 Sets the Vector2 value associated with this key, in prefBase, to the provided Vector3. Behind the scenes, the values are stored as two key-float pairs, key+"X", and key+"Y" in prefBase
 
static void SetVector3 (this IStorePreferences interfaceReference, string key, Vector3 vector)
 Sets the Vector3 value associated with this key, in prefBase, to the provided Vector3. Behind the scenes, the values are stored as three key-float pairs, key+"X", key+"Y" and key+"Z" in prefBase