Unity-SerializableDictionary icon indicating copy to clipboard operation
Unity-SerializableDictionary copied to clipboard

New key makes Unity lag

Open Defozo opened this issue 4 years ago • 2 comments

After adding new key Unity lags. The lag stops after making key unique and not null.

Defozo avatar Apr 01 '20 13:04 Defozo

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 = "";

rainbowcreatures avatar Nov 03 '20 15:11 rainbowcreatures

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 ?

azixMcAze avatar Apr 07 '21 09:04 azixMcAze