Download. Works with all Unity versions
Just simpy import Unity Package it contains only several scripts and it ready to use!
This SerializableDictionary provides functionality similar to Unity's Dictionary<TKey, TValue>, allowing it to be displayed in the Unity Inspector. Works also with Odin Inspector and without
Example script
public SerializableDictionary<int, string> intToStringDictionary;
It can automatically detect duplicates and display them in the Inspector
Also in Debugger when it will be called
Serialize Interfaces From Version 2.01 and above
You can simply clone the project and check the results. Here is a very simple example for use
using ProjectTools;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class Example : MonoBehaviour
{
[SerializeField] private Text GeorgeLabel;
[SerializeField] private Image GeorgeImage;
[SerializeField] private Text ThemisLabel;
[SerializeField] private Image ThemisImage;
[SerializeField] private SerializableDictionary<int, string> intToStringDictionary;
[SerializeField] private SerializableDictionary<string, Color> stringToColorDictionary;
[SerializeField] private SerializableDictionary<string, int[]> stringToIntArrayDictionary;
private const string GeorgeName = "George";
private const string ThemisName = "Themis";
private void Start()
{
TestSetup();
}
public void TestSetup()
{
GeorgeLabel.text = intToStringDictionary[0];
ThemisLabel.text = intToStringDictionary[1];
GeorgeImage.color = stringToColorDictionary[GeorgeName];
ThemisImage.color = stringToColorDictionary[ThemisName];
}
}