docs.unity3d.com
    Show / Hide Table of Contents

    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.

    Inheritance
    Object
    Dictionary<K, V>
    SerializedDictionary<K, V, K, V>
    SerializedDictionary<K, V>
    Inherited Members
    SerializedDictionary<K, V, K, V>.SerializeKey(K)
    SerializedDictionary<K, V, K, V>.SerializeValue(V)
    SerializedDictionary<K, V, K, V>.DeserializeKey(K)
    SerializedDictionary<K, V, K, V>.DeserializeValue(V)
    SerializedDictionary<K, V, K, V>.OnBeforeSerialize()
    SerializedDictionary<K, V, K, V>.OnAfterDeserialize()
    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)

    Extension Methods

    ReflectionUtils.Invoke(Object, String, Object[])
    ReflectionUtils.SetField(Object, String, Object)
    ReflectionUtils.GetField(Object, String)
    ReflectionUtils.GetFields(Object)
    In This Article
    • Methods
      • DeserializeKey(K)
      • DeserializeValue(V)
      • SerializeKey(K)
      • SerializeValue(V)
    • Extension Methods
    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023