Class KeyDataStore
Contains serialized data in a generic serializable container.
Namespace: UnityEditor.AddressableAssets.Settings
Syntax
[Serializable]
public class KeyDataStore : ISerializationCallbackReceiver
Properties
Keys
The collection of keys stored.
Declaration
public IEnumerable<string> Keys { get; }
Property Value
Type | Description |
---|---|
IEnumerable<String> |
OnSetData
Delegate that is invoked when data is modified.
Declaration
public Action<string, object, bool> OnSetData { get; set; }
Property Value
Type | Description |
---|---|
Action<String, Object, 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 |
---|---|---|
String | key | The key. |
T | defaultValue | The default value to return if the data is not found. |
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 |
---|---|---|
String | key | The key. |
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 |
---|---|---|
String | key | The data key. |
String | data | The data string value. |