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
- Channel remapping dropdown in the Terrain Layer does not open when clicked on the title
- The Editor freezes indefinitely when a large number of elements are entered in the Subgraphs or Categories lists
- Some Visual Effects package Assets links to documentation are not working
- Heatmap asset’s documentation button in the Inspector window leads to “Sorry... that page seems to be missing!” page when clicked
- Crash on MonoBehaviour::CallMethodIfAvailable when performing various actions
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.