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
- Texture2D hash changes inside of an AssetBundle when rebuilding a SpriteAtlas bundle with an empty AssetPostprocessor Script enabled
- Aniso Level still applies when Generate MipMap is disabled in Texture Import Settings
- Mipmap Limit Groups long names are not truncated when creating a new Mipmap Limit Group with a long name
- “ArgumentException: Invalid double parameter.” error is thrown when Infinity is typed into the Fixed Timestep field
- GameObject becomes gray when using HDRP and STP together on macOS
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.