Search Issue Tracker
UIToolkit with UIDocument - InvalidOperationException
1. What happened
- Changing any value to any VisualElement in UIBuilder or via scripts creates an error (Invalid Operation Exception, see the stacktrace below).
2. How can we reproduce it using the example you attached
- Open the scene file
- Select UIDocument in the scene, open Test (Visual Tree Asset) so UI Builder opens up
- Do anything to any element (Label) in the tree, e.g. change opacity, position, apply any style (via editor or style script) and the error message will appear in the console
This error occours in Unity 2022.1.b5 and 2022.1.b6. No errors with 2021.2.10f1 version.
InvalidOperationException: Collection was modified; enumeration operation may not execute.
System.Collections.Generic.List`1+Enumerator[T].MoveNextRare () (at <cdc4992cc04a4e77a24a09cd121af77b>:0)
System.Collections.Generic.List`1+Enumerator[T].MoveNext () (at <cdc4992cc04a4e77a24a09cd121af77b>:0)
UnityEngine.UIElements.UIElementsRuntimeUtility.UpdateRuntimePanels () (at <9fb9706855a847a1926259ab0baf1b3c>:0)
UnityEngine.UIElements.UIElementsRuntimeUtilityNative.UpdateRuntimePanels () (at <05a8bc2f25e84bdebc90d31147b4881d>:0)
Note: We tried on Windows and it looks like its affecting MAC only.
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
- [2D][URP] Lights produce diagonal artefacts when normal maps are set on Sprites
- Render Feature causing black screen only on some iOS devices
- Gizmo does not update correctly when moving a Box Collider 2D and Time Scale is less than 1
- Canvas with Render Mode "Screen Space - Camera" is not rendered when Lens Flare is enabled
- GameObject bounces differently in Player compared to Play Mode