Search Issue Tracker
By Design
Votes
0
Found in [Package]
1.0.0-preview.7
Issue ID
1286177
Regression
Yes
[UI Toolkit] A script stops updating the Elements when the UI Document is disabled and re-enabled while in the Play Mode
How to reproduce:
1. Open user's attached "UI Tookit Bug Test" project
2. Open the "TestUI" Scene
3. Enter the Play Mode
4. In the Game view press the button
Expected results: The button text stays the same, continues counting
Actual results: The button text is set to say "Button", the script doesn't update the text anymore
Reproducible with: 1.0.0-preview.7, 1.0.0-preview.9 (2020.1.13f1, 2020.2.0b11, 2021.1.0a5)
Not reproducible with: 1.0.0-preview.6 (2020.1.13f1, 2020.2.0b11, 2021.1.0a5)
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- GetCurrentAnimatorClipInfoCount() and GetNextAnimatorClipInfoCount() return 0 when animator is in transition
- GPU utilization increases by 20% on Meta Quest headsets when Render Graph is enabled on 6000.0.16f1 and higher
- Value on Slider (Int) control in UI Builder displays as default when saving UI Document
- Color mismatch in UI Builders Library panel when the Editors theme is set to Light Mode
- [Android ] "AndroidJNI.ToBooleanArray" returns a random non-zero value instead of "IntPtr.Zero" when the method argument is null
Resolution Note:
Right now a UIDocument will have its visual tree recreated when disabled and re-enabled, as explained on this forum post, related to the Live Reload feature: https://forum.unity.com/threads/feeback-wanted-ui-assets-live-reload.963129/
Since the visual tree is re-created, the reference to the button instance retrieved by UITester is no longer the button you see on the Game View. The pattern suggested is for references to VisualElements to be retrieved on the OnEnable method of companion classes (in this case, of the UITester class for example) and for Live Reload to work properly as the whole UI gets reloaded.
If a UIDocument must be disabled/re-enabled for some reason, we recommend the whole game object be disabled/re-enabled, but if the disabling is about hiding something from the UI, then we highly suggest setting the display of the root visual element to none (and back to flex when it is made to be visible again) as this is more efficient and the UI Toolkit way of showing/hiding stuff.