Table of Contents

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

TKey

The type of the dictionary keys

TValue

The type of the dictionary values

Inheritance
object
SerializableDictionary<TKey, TValue>

Properties

this[TKey]

Gets or sets the value associated with the specified key.

public TValue this[TKey key] { get; set; }

Parameters

key TKey

The 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

key TKey

The 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

key TKey

The key to locate

value TValue

The 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

serializableDictionary SerializableDictionary<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

dictionary Dictionary<TKey, TValue>

Returns

SerializableDictionary<TKey, TValue>