Class SerializableDictionary<TKey, TValue>
- Namespace
- ElectricDrill.SoapRpgFramework.Utils
- Assembly
- com.electricdrill.soap-rpg-framework.Runtime.dll
A serializable dictionary implementation that can be displayed and edited in the Unity Inspector. Provides all standard dictionary functionality while maintaining Unity serialization compatibility.
[Serializable]
public class SerializableDictionary<TKey, TValue>
Type Parameters
TKeyThe type of the dictionary keys
TValueThe type of the dictionary values
- Inheritance
-
objectSerializableDictionary<TKey, TValue>
Properties
this[TKey]
Gets or sets the value associated with the specified key.
public TValue this[TKey key] { get; set; }
Parameters
keyTKeyThe key of the value to get or set
Property Value
- TValue
The value associated with the specified key
Keys
Gets a collection containing the keys in the dictionary.
public Dictionary<TKey, TValue>.KeyCollection Keys { get; }
Property Value
- Dictionary<TKey, TValue>.KeyCollection
Values
Gets a collection containing the values in the dictionary.
public Dictionary<TKey, TValue>.ValueCollection Values { get; }
Property Value
- Dictionary<TKey, TValue>.ValueCollection
Methods
Clear()
Removes all keys and values from the dictionary.
public void Clear()
ContainsKey(TKey)
Determines whether the dictionary contains the specified key.
public bool ContainsKey(TKey key)
Parameters
keyTKeyThe key to locate
Returns
- bool
True if the dictionary contains the key; otherwise, false
GetEnumerator()
Returns an enumerator that iterates through the dictionary.
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
Returns
- IEnumerator<KeyValuePair<TKey, TValue>>
An enumerator for the dictionary
OnAfterDeserialize()
Reconstructs the internal dictionary from the serialized list format. Called automatically by Unity after deserialization occurs.
public void OnAfterDeserialize()
OnBeforeSerialize()
Converts the internal dictionary to a serialized list format for Unity serialization. Called automatically by Unity before serialization occurs.
public void OnBeforeSerialize()
TryGetValue(TKey, out TValue)
Attempts to get the value associated with the specified key.
public bool TryGetValue(TKey key, out TValue value)
Parameters
keyTKeyThe key to locate
valueTValueThe value associated with the key, if found
Returns
- bool
True if the key was found; otherwise, false
Operators
implicit operator Dictionary<TKey, TValue>(SerializableDictionary<TKey, TValue>)
public static implicit operator Dictionary<TKey, TValue>(SerializableDictionary<TKey, TValue> serializableDictionary)
Parameters
serializableDictionarySerializableDictionary<TKey, TValue>
Returns
- Dictionary<TKey, TValue>
implicit operator SerializableDictionary<TKey, TValue>(Dictionary<TKey, TValue>)
public static implicit operator SerializableDictionary<TKey, TValue>(Dictionary<TKey, TValue> dictionary)
Parameters
dictionaryDictionary<TKey, TValue>
Returns
- SerializableDictionary<TKey, TValue>