Unity-SerializableDictionary
Unity-SerializableDictionary copied to clipboard
New key makes Unity lag
After adding new key Unity lags. The lag stops after making key unique and not null.
Yeah, each time you add a new property (string in my case), it is a duplicate key based on the previous entry. Which triggers a warning about duplicate keys, which makes the whole component go crazy - it keeps on reloading. That makes it impossible to add a new key to multiple prefabs at once, because the reload lag gets too much, and you can't click inside.
Because I'm still new in Unity, I found a quick workaround for my case, I'm setting the new key to empty string right after adding. That avoids the warning and thus the crazy reloads.
if(buttonAction == Action.Add)
{
keyArrayProperty.InsertArrayElementAtIndex(buttonActionIndex);
// My workaround
SerializedProperty newProp = keyArrayProperty.GetArrayElementAtIndex(buttonActionIndex);
newProp.stringValue = "";
Hi, I could not reproduce a big lag in the editor. I tried adding an entry to a SerializableDictionnary in 100 GameObjects and while there was a small lag when editing the fields, it was still pretty usable.
Which version of unity are you using ? Have you tried with the version in the master branch ?