Class KeyDataStore
Contains serialized data in a generic serializable container.
Inheritance
Namespace: UnityEditor.AddressableAssets
Syntax
public class KeyDataStore : ISerializationCallbackReceiver
Properties
Keys
The collection of keys stored.
Declaration
public IEnumerable<string> Keys { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.String> |
OnSetData
Delegate that is invoked when data is modified.
Declaration
public Action<string, object, bool> OnSetData { get; set; }
Property Value
Type | Description |
---|---|
Action<System.String, System.Object, System.Boolean> |
Methods
GetData<T>(String, T, Boolean)
Get data via a specified key.
Declaration
public T GetData<T>(string key, T defaultValue, bool addDefault = false)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key. |
T | defaultValue | The default value to return if the data is not found. |
System.Boolean | addDefault | Optional parameter to control whether to add the default value if the data is not found. |
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T | The data type. |
OnAfterDeserialize()
Implementation of ISerializationCallbackReceiver interface, used to convert data from its serializable form.
Declaration
public void OnAfterDeserialize()
OnBeforeSerialize()
Implementation of ISerializationCallbackReceiver interface, used to convert data to a serializable form.
Declaration
public void OnBeforeSerialize()
SetData(String, Object)
Set the value of a specified key.
Declaration
public void SetData(string key, object data)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key. |
System.Object | data | The data to store. Supported types are strings, POD types, objects that have a static method named 'Parse' that convert a string to an object, and object that are serializable via JSONUtilty. |
SetDataFromString(String, String)
Set data for a specified key from a string.
Declaration
public void SetDataFromString(string key, string data)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The data key. |
System.String | data | The data string value. |