Serializable Dictionary, HashSet and KeyValuePair-style types with reorderable Unity Inspector controls.
This project was developed from azixMcAze's Unity-SerializableDictionary. See Third-Party Notices.
- Unity 2022.3 or newer.
- Key and value types must follow Unity's serialization rules.
The package is tested with Unity 2022.3 LTS and Unity 6.
Run this command in the Unity project directory:
openupm add com.strodio.serializable-dictionarySee the OpenUPM package page for scoped-registry installation.
In Package Manager, select Add package from git URL and enter:
https://github.com/StromKuo/SerializableDictionary.git
For reproducible builds, append a release tag such as #v0.2.0.
using System;
using SKUnityToolkit.SerializableDictionary;
using UnityEngine;
public class Inventory : MonoBehaviour
{
[SerializeField]
SerializableDictionary<string, int> itemCounts = new SerializableDictionary<string, int>();
[SerializeField]
SerializableHashSet<string> unlockedItems = new SerializableHashSet<string>();
[SerializeField]
SerializableKeyValuePair<string, Color> categoryColor =
new SerializableKeyValuePair<string, Color>("Default", Color.white);
}The types derive from the standard collection implementations, so normal dictionary and set APIs are available at runtime.
Unity does not directly serialize nested containers. Wrap the inner collection in a serializable class:
using System;
using System.Collections.Generic;
using UnityEngine;
[Serializable]
public class ColorList
{
public List<Color> values = new List<Color>();
}
[SerializeField]
SerializableDictionary<string, ColorList> colorsByCategory =
new SerializableDictionary<string, ColorList>();- The first entry for a duplicate dictionary key is retained; later duplicates are discarded.
- Null and destroyed
UnityEngine.Objectkeys are discarded. DeserializationConflictCountreports how many dictionary or HashSet entries were discarded by the latest deserialization.- Custom equality comparers affect only the current in-memory instance and are not serialized by Unity.
- Serialization order follows collection enumeration order and must not be used as application logic.
See the full documentation, changelog, and the Basic Usage sample available from Package Manager.

