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
- Reflection Probe “Probe Scene Editing Mode:” text is barely visible
- [HDRP] Game view doesn’t refresh after changing Camera Background Type until mouse moves over it
- Some Shaders appear twice in Material Shader selection menu
- Editor freezes with a StackOverflowException when certain asset types are assigned to a managed component in a SubScene via AddComponentObject
- Scale Snapping with Gizmos does not work in the Scene view when Snapping and Absolute Grid Snapping are toggled off
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.