The issue is, that a dictionary cannot contain the same key multiple times, but when Unity creates a new entry of your list, whenever you resize it in the inspector, it will just copy the last item. In this caseThis means, or even if it would createyou are trying to add a new empty instance, the key of the entry would be either empty string or the last items key, which causesalready exists to the dictionary to. This doesn't work and could throw an exception (in my case where I've changed the code to use the Add method). In, but in your case, you were simply replacing the existing key with a new value of the copied entry, so the first entry was always override bywith the new one, therefore never growing bigger than one.
public void OnAfterDeserialize()
{
// No need to create the dictionary again, just clear it out.
resources.Clear();
foreach (ResourceEntry entry in entries)
{
// This "works" but hides your mistake.
// If resources[key] doesn't exist or already exists,
// this key will simply be created or overriden.
resources[entry.key] = entry.value;
// To show the mistake, make this line explicitly throw an error
// when you try to add a key, that already exists:
resources.Add(entry.key, entry.value);
}
}
Now you will notice, that you are trying to add the same key twice, which throws an error. To work around this, you can easily use your existing custom editor and instead of copying the last item, create a new one with a unique key.