unity show dictionary in inspector
/*
* Unity cannot serialize dictionaries by default. Make a struct/class
* that contains a key and a value, and expose a list of those objects.
* Then populate your dictionary from that list in Awake() or Start():
*/
[Serializable]
public class KeyValuePair {
public MyKeyType key;
public MyValueType val;
}
public List<KeyValuePair> MyList = new List<KeyValuePair>();
Dictionary<MyKeyType, MyValueType> myDict = new Dictionary<MyKeyType, MyValueType>();
void Awake() {
foreach (var kvp in MyList) {
myDict[kvp.key] = kvp.val;
}
}