I've been writing some custom UI for a ScriptableObject with an array. I create a `PropertyField` for every element in the array, and noticed that around 20 elements, Unity is taking over 25ms on `Bindings.Update` every few frames after the UI has been created. Once I hit about 40 elements, the UI becomes totally unresponsive. A quick profile shows that almost all time is spend in `SerializedProperty.get_isValid()` The image below is at 30 elements. Does anyone have a suggestion on how to remove/reduce this insane overhead?
No problem The attached file contains the editor The ScriptableObject itself looks like this: Code (CSharp): public class EntityRepresentationMapping : ScriptableObject { [SerializeReference] public List<IEntityRepresentationResolver> EntityRepresentationResolvers = new List<IEntityRepresentationResolver>(); }
One pitfall of the current api implementation is that BindProperty() will involve serializing the entire object every frame. This can be avoided by simply calling Bind() at the root level of your hierarchy and bind everything at once. This usage is fixed in one of our development branch and should ship soon. I modified your implementation a bit, let me know if that improves the situation.
Thank you very much for taking the time to look at the issue! Sadly it seems the fix has little impact. An array with 30 elements still takes between 20 and 30ms during `Bindings.Update` every few (7?) frames. Will this fix be applied only to the 2020.2 beta, or also a 2020.1 patch?
The fix will be available in the package version of UIToolkit, available for 2020.2 and 2020.1. Can you report the issue using Help -> Report a Bug ... ? That will help us getting the fix backported to the built-in editor versions.
Hi folks, I'm running into the same serializedObject updating every frame slowdown issue here. I've used the same pattern you explain here of having the highest parent possible Bind once but agree with MartijnGG that forcing large lists to rebuild whenever changed isn't really workable. What's the status on this fix going into the UIToolkit package for 2020.1?