Search Issue Tracker
By Design
By Design in 2023.3.X
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
- [HDRP] Volumetric cloud shadows disappear when there is no directional light shadows
- “Selector” column names in the Search window are lowercase when added
- Install List Project Counter Panel can be right clicked through and Install Context Menu can be opened disabling Project Counter Panel's buttons
- Scene is marked/flickering as dirty (with asterisk) when dragging a Material on a GameObject in Scene view
- Warning icon for the "Asset Import Overrides" has low visibility in Light Unity theme
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.
Resolution Note (2023.3.X):
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.