Search Issue Tracker
By Design
Votes
0
Found in
2021.3.35f1
2022.3.20f1
2023.2.11f1
2023.3.0b8
Issue ID
UUM-64345
Regression
No
”style.display” on UI Elements stops working when the UI Document (or its parent) is disabled and re-enabled
How to reproduce:
1. Open the attached “display.zip” project
2. Enter “SampleScene” Scene (Assets > Scenes)
3. Enter Play Mode
4. Observe the Game view
5. In the Hierarchy window, select “UIDocument” GameObject
6. In the Inspector window, disable and enable the “UI Document” Component
7. Observe the Game view
Expected result: All elements are visible
Actual result: Some elements disappear
Reproducible with: 2021.3.35f1, 2022.3.20f1, 2023.2.11f1, 2023.3.0b8
Reproduced on: macOS 14.2.1 (Intel)
Not reproducible on: No other environment tested
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
- [Shader Graph][Ubuntu] Create Note menu can't be resized smaller, jumps in size and position
- Text is overlapping when using RTL
- Tile Asset Inspector "Flags" fields dropdown has an empty space below the options and has a different design than other dropdowns
- Shader cache is not used when building the Player repeatedly
- Shaders are always recompiled when the Editor is opened
Resolution Note:
This is a current limitation on how UIDocuments behave when disabled and re-enabled. When doing so, the UIDocument will re-create its UI. This means that VisualElements that are held in private member are basically "stale", and modifying them will not have any impact.
There are many ways to work around this limitation. A simple one is to register a "detached from panel event" to the root element (using root.RegisterCallback<DetachFromPanelEvent>) to know if the UIDocument was disabled. Then, once the root element is not null anymore, you can refresh your private VisualElement members.