Beta9: Details on serialized Dictionnaries?

So now, from what I understand, it’s possible to serialize Dictionnaries by making a class that inherits from Dictionnary. However, with a quick test, I wasn’t able to make it work. Here’s what I did:

[System.Serializable]
public class SerializedDictionnary : Dictionary<string, int>
{
}
public class Tester : MonoBehaviour
{
    public SerializedDictionnary TestDict = new SerializedDictionnary();
}

Is there anything else I need to do? And is it supposed to appear in the inspector as an editable list of keyvalue pairs?

Edit: I tried adding values to my dictionnary in editor with scripting, and then pressing play, and the values didn’t carry over to play mode either. So it’s not just that my values don’t appear in the inspector

1 Like

Try adding the serializable tag to the field:

[SerializeField]
public SerializedDictionnary TestDict = new SerializedDictionnary();

Sorry for brevity, on my mobile phone.

tried that too, still not working

The release note is for the specific situation where you have inherited from Dictionary and added your own serialised fields in your subclass. The fields in Dictionary itself are not serialised, and the serialiser has no special understanding of Dictionary as a class - it just doesn’t blacklist subclasses of it like it did before this change.

1 Like

You misspelled “Dictionary” as “Dictionarry”.