HiddenVars
Derived from
IDisposable
Main class for HiddenVars. Also only public class.
New instance can be create with normal constructor, new HiddenVars() or new HiddenVars(string) . After that, values can be written or read, using Set and Get methods.
Note that when reading lists from HiddenVars, returned plain value is copy of hidden value. Meaning that if any changes are made to plain value list, it does not change value stored in HiddenVars, until Set method is used again to overwrite old value in HiddenVars instance. For example:
HiddenVars hiddenVars = new HiddenVars(); hiddenVars.SetIntList("someKey",new int[]{0,1,2,3,4}); IList<int> intListFromHV = hiddenVars.GetIntList("someKey"); intListFromHV[0] = 5; Debug.Log(hiddenVars.GetIntList("someKey")[0]); // Prints out "0", previous line didn't change value stored to HiddenVars instance hiddenVars.SetIntList("someKey",intListFromHV); // Saves the modified list to HiddenVars instance Debug.Log(hiddenVars.GetIntList("someKey")[0]); // Prints out "5"
Constructors
Indexer
Properties
public int Count | Returns count of key/value pairs in this instance. |
Methods
public void Clear () | Remove all the keys and values. | public bool ContainsKey (string key) | Checks whether any type of value identified by key exists. | public void Dispose () | Clear and destroy this instance. | public bool GetBool (string key) | Get boolean value identified by key. | public bool GetBool (string key, bool defaultValue) | Get boolean value identified by key or default value if key is not found. | public List GetBoolList (string key) | Get boolean list identified by key. | public List GetBoolList (string key, List defaultList) | Get bool list identified by key or default list if key is not found. | public byte[] GetByteArray (string key) | Get byte array identified by key. | public byte[] GetByteArray (string key, byte[] defaultArray) | Get byte array identified by key or default value if key is not found. | public double GetDouble (string key) | Get double value identified by key. | public double GetDouble (string key, double defaultValue) | Get double value identified by key or default value if key is not found. | public List GetDoubleList (string key) | Get double list identified by key. | public List GetDoubleList (string key, List defaultList) | Get double list identified by key or default list if key is not found. | public float GetFloat (string key) | Get float value identified by key. | public float GetFloat (string key, float defaultValue) | Get float value identified by key or default value if key is not found. | public List GetFloatList (string key) | Get float list identified by key. | public List GetFloatList (string key, List defaultList) | Get float list identified by key or default list if key is not found. | public int GetInt (string key) | Get integer value identified by key. | public int GetInt (string key, int defaultValue) | Get integer value identified by key or default value if key is not found. | public List GetIntList (string key) | Get integer list identified by key. | public List GetIntList (string key, List defaultList) | Get integer list identified by key or default list if key is not found. | public string[] GetKeys () | Get list of all keys in this instance. | public long GetLong (string key) | Get long value identified by key. | public long GetLong (string key, long defaultValue) | Get long value identified by key or default value if key is not found. | public List GetLongList (string key) | Get long list identified by key. | public List GetLongList (string key, List defaultList) | Get long list identified by key or default list if key is not found. | public string GetString (string key) | Get string identified by key. | public string GetString (string key, string defaultValue) | Get string identified by key or default value if key is not found. | public bool Remove (string key) | Remove any type of value identified by key. | public void SetBool (string key, bool value) | Set boolean value identified by key. | public void SetBoolList (string key, IList values) | Set boolean list identified by key. | public void SetByteArray (string key, byte[] value) | Set byte array identified by key. | public void SetDouble (string key, double value) | Set double value identified by key. | public void SetDoubleList (string key, IList values) | Set double list identified by key. | public void SetFloat (string key, float value) | Set float value identified by key. | public void SetFloatList (string key, IList values) | Set float list identified by key. | public void SetInt (string key, int value) | Set integer value identified by key. | public void SetIntList (string key, IList values) | Set integer list identified by key. | public void SetLong (string key, long value) | Set long value identified by key. | public void SetLongList (string key, IList values) | Set long list identified by key. | public void SetString (string key, string value) | Set string value identified by key. |
Constructors
public HiddenVars () Initializes a new instance of the HiddenVars class.
public HiddenVars (string nameForDebug) Initializes a new instance of the HiddenVars class with specific debug name. Debug name have no effect to actual functionality of this class and have meaning only when running application in Unity Editor. Parameters | nameForDebug | Debug name for this instance, visible in "HiddenVars EditorOnly RunTimeDebug" game object in the Unity Editor when application is running. There can be multiple instances of HiddenVars with same debug name. If parameter is null, default name is generated. |
Indexer
public int this [string key] Gets or sets integer value with the specified key. Functionality is identical compared to using GetInt and SetInt methods. Parameters | key | Key of the value to set or get |
Properties
public int Count Returns count of key/value pairs in this instance.
Methods
public void Clear () Remove all the keys and values.
public bool ContainsKey (string key) Checks whether any type of value identified by key exists. Parameters | key | Key to locate |
Returns | True if key and value exists |
public void Dispose () Clear and destroy this instance. This method will also remove instance from RunTimeDebug object if running application in Unity Editor. After calling this method, instance is not usable any more and trying to add or read any values will cause exception.
public bool GetBool (string key) Get boolean value identified by key. Parameters | key | Key of the boolean value to get |
Exceptions | KeyNotFoundException | Value with specified key doesn't exist |
public bool GetBool (string key, bool defaultValue) Get boolean value identified by key or default value if key is not found. Parameters | key | Key of the boolean value to get | | defaultValue | Default boolean value to return if key does not exist |
Returns | Boolean value or default boolean value |
public List GetBoolList (string key) Get boolean list identified by key. Parameters | key | Key of the boolean list to get |
Exceptions | KeyNotFoundException | Value with specified key doesn't exist |
public List GetBoolList (string key, List defaultList) Get bool list identified by key or default list if key is not found. Parameters | key | Key of the bool list to get | | defaultList | Default bool list to return if key does not exist |
public byte[] GetByteArray (string key) Get byte array identified by key. Parameters | key | Key of the byte array to get |
Exceptions | KeyNotFoundException | Value with specified key doesn't exist |
public byte[] GetByteArray (string key, byte[] defaultArray) Get byte array identified by key or default value if key is not found. Parameters | key | Key of the byte array to get | | defaultArray | Default byte array to return if key does not exist (may be null) |
Returns | Byte array or default byte array |
public double GetDouble (string key) Get double value identified by key. Parameters | key | Key of the double value to get |
Exceptions | KeyNotFoundException | Value with specified key doesn't exist |
public double GetDouble (string key, double defaultValue) Get double value identified by key or default value if key is not found. Parameters | key | Key of the double value to get | | defaultValue | Default double value to return if key does not exist |
Returns | Double value or default value |
public List GetDoubleList (string key) Get double list identified by key. Parameters | key | Key of the double list to get |
Exceptions | KeyNotFoundException | Value with specified key doesn't exist |
public List GetDoubleList (string key, List defaultList) Get double list identified by key or default list if key is not found. Parameters | key | Key of the double list to get | | defaultList | Default double list to return if key does not exist |
public float GetFloat (string key) Get float value identified by key. Parameters | key | Key of the float value to get |
Exceptions | KeyNotFoundException | Value with specified key doesn't exist |
public float GetFloat (string key, float defaultValue) Get float value identified by key or default value if key is not found. Parameters | key | Key of the float value to get | | defaultValue | Default float value to return if key does not exist |
Returns | Float value or default float value |
public List GetFloatList (string key) Get float list identified by key. Parameters | key | Key of the float list to get |
Exceptions | KeyNotFoundException | Value with specified key doesn't exist |
public List GetFloatList (string key, List defaultList) Get float list identified by key or default list if key is not found. Parameters | key | Key of the float list to get | | defaultList | Default float list to return if key does not exist |
public int GetInt (string key) Get integer value identified by key. Parameters | key | Key of the integer value to get |
Exceptions | KeyNotFoundException | Value with specified key doesn't exist |
public int GetInt (string key, int defaultValue) Get integer value identified by key or default value if key is not found. Parameters | key | Key of the integer value to get | | defaultValue | Default integer value to return if key does not exist |
Returns | Integer value or default integer value |
public List GetIntList (string key) Get integer list identified by key. Parameters | key | Key of the integer list to get |
Exceptions | KeyNotFoundException | Value with specified key doesn't exist |
public List GetIntList (string key, List defaultList) Get integer list identified by key or default list if key is not found. Parameters | key | Key of the integer list to get | | defaultList | Default integer list to return if key does not exist |
public string[] GetKeys () Get list of all keys in this instance. Returned array is copy of the keys at the moment when this method was called. Changing values or setting them null in returned array doesn't affect this HiddenVars instance in any way. Returns | Array of string keys. |
public long GetLong (string key) Get long value identified by key. Parameters | key | Key of the long value to get |
Exceptions | KeyNotFoundException | Value with specified key doesn't exist |
public long GetLong (string key, long defaultValue) Get long value identified by key or default value if key is not found. Parameters | key | Key of the long value to get | | defaultValue | Default long value to return if key does not exist |
Returns | Long value or default value |
public List GetLongList (string key) Get long list identified by key. Parameters | key | Key of the long list to get |
Exceptions | KeyNotFoundException | Value with specified key doesn't exist |
public List GetLongList (string key, List defaultList) Get long list identified by key or default list if key is not found. Parameters | key | Key of the long list to get | | defaultList | Default long list to return if key does not exist |
public string GetString (string key) Get string identified by key. Parameters | key | Key of the string to get |
Exceptions | KeyNotFoundException | Value with specified key doesn't exist |
public string GetString (string key, string defaultValue) Get string identified by key or default value if key is not found. Parameters | key | Key of the string to get | | defaultValue | Default string value to return if key does not exist (may be null) |
Returns | String or default string |
public bool Remove (string key) Remove any type of value identified by key. Parameters | key | Key of the value to be removed |
Returns | True if key was found and value removed, otherwise false |
public void SetBool (string key, bool value) Set boolean value identified by key. If there's any previous value with same key, it will be replaced. Parameters | key | Key of the boolean value to set | | value | Boolean value to be hidden |
public void SetBoolList (string key, IList values) Set boolean list identified by key. If there's any previous value with same key, it will be replaced. Parameters | key | Key of the boolean list to set | | values | Boolean list to be hidden |
public void SetByteArray (string key, byte[] value) Set byte array identified by key. If there's any previous value with same key, it will be replaced. Parameters | key | Key of the byte array to set | | value | Byte array to be hidden (can not be null but length may be zero) |
public void SetDouble (string key, double value) Set double value identified by key. If there's any previous value with same key, it will be replaced. Parameters | key | Key of the double value to set | | value | Double value to be hidden (may be NaN, positive infinity or negative infinity) |
public void SetDoubleList (string key, IList values) Set double list identified by key. If there's any previous value with same key, it will be replaced. Parameters | key | Key of the double list to set | | values | Double list to be hidden |
public void SetFloat (string key, float value) Set float value identified by key. If there's any previous value with same key, it will be replaced. Parameters | key | Key of the float value to set | | value | Float value to be hidden (may be NaN, positive infinity or negative infinity) |
public void SetFloatList (string key, IList values) Set float list identified by key. If there's any previous value with same key, it will be replaced. Parameters | key | Key of the float list to set | | values | Float list to be hidden |
public void SetInt (string key, int value) Set integer value identified by key. If there's any previous value with same key, it will be replaced. Parameters | key | Key of the integer value to set | | value | Integer value to be hidden |
public void SetIntList (string key, IList values) Set integer list identified by key. If there's any previous value with same key, it will be replaced. Parameters | key | Key of the integer list to set | | values | Integer list to be hidden |
public void SetLong (string key, long value) Set long value identified by key. If there's any previous value with same key, it will be replaced. Parameters | key | Key of the long value to set | | value | Long value to be hidden |
public void SetLongList (string key, IList values) Set long list identified by key. If there's any previous value with same key, it will be replaced. Parameters | key | Key of the long list to set | | values | Long list to be hidden |
public void SetString (string key, string value) Set string value identified by key. If there's any previous value with same key, it will be replaced. Parameters | key | Key of the string value to set | | value | String to be hidden (can not be null but length may be zero) |
|