Class SerializedDictionary<K, V>
Unity can't serialize Dictionary so here's a custom wrapper that does. Note that you have to extend it before it can be serialized as Unity won't serialized generic-based types either.
Inherited Members
Namespace: UnityEngine.Rendering
Syntax
[Serializable]
public class SerializedDictionary<K, V> : SerializedDictionary<K, V, K, V>, IDictionary<K, V>, ICollection<KeyValuePair<K, V>>, IReadOnlyDictionary<K, V>, IReadOnlyCollection<KeyValuePair<K, V>>, IEnumerable<KeyValuePair<K, V>>, IDictionary, ICollection, IEnumerable, IDeserializationCallback, ISerializable, ISerializationCallbackReceiver
Type Parameters
Name | Description |
---|---|
K | The key type |
V | The value |
Examples
public sealed class MyDictionary : SerializedDictionary<KeyType, ValueType> {}
Methods
DeserializeKey(K)
Conversion to serialize a key
Declaration
public override K DeserializeKey(K key)
Parameters
Type | Name | Description |
---|---|---|
K | key | The key to serialize |
Returns
Type | Description |
---|---|
K | The Key that has been serialized |
Overrides
UnityEngine.Rendering.SerializedDictionary<K, V, K, V>.DeserializeKey(K)
DeserializeValue(V)
Conversion to serialize a value
Declaration
public override V DeserializeValue(V val)
Parameters
Type | Name | Description |
---|---|---|
V | val | The value |
Returns
Type | Description |
---|---|
V | The value |
Overrides
UnityEngine.Rendering.SerializedDictionary<K, V, K, V>.DeserializeValue(V)
SerializeKey(K)
Conversion to serialize a key
Declaration
public override K SerializeKey(K key)
Parameters
Type | Name | Description |
---|---|---|
K | key | The key to serialize |
Returns
Type | Description |
---|---|
K | The Key that has been serialized |
Overrides
UnityEngine.Rendering.SerializedDictionary<K, V, K, V>.SerializeKey(K)
SerializeValue(V)
Conversion to serialize a value
Declaration
public override V SerializeValue(V val)
Parameters
Type | Name | Description |
---|---|---|
V | val | The value |
Returns
Type | Description |
---|---|
V | The value |
Overrides
UnityEngine.Rendering.SerializedDictionary<K, V, K, V>.SerializeValue(V)