Serialization of Dictionary with custom classes

I got this dictionary (key is an enum, value is a list of another custom class) in a custom class im trying to trying to get to show up in my editor. I’m not interested in saving the data for to be loaded later or anything (atleast, not yet), I just want to be able to see all the values in the editor. Here’s the code with the irrelevant bits taken out.

[Serializable]
public class Items : ScriptableObject
{
    public int maxStackSize = 10;

    [Serializable]
    public enum Type
    {
        Berry,
        Rock,
        Wood
    }
}

[Serializable]
public class Harvestable : Entity
{
    public Items.Type itemType; // the item type this harvestable provides
}

[Serializable]
public class Knowledge
{
    [SerializeField] private Dictionary<Items.Type, List<Harvestable>> knownResources = new Dictionary<Items.Type, List<Harvestable>>(); // This is what I want to see in the inspector
}

public class AIController : Entity
{
    [SerializeField] Knowledge knowledge;
}

184602-delete-me.png

As you can see, I have the ‘Knowledge’ field showing up in the editor, but not the dictionary that I’m trying to inspect.

Unity cannot serialize dictionaries. However, since it’s something many people want, there are many implementations available for you to integrate into your project, like this one.