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

  1. 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.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.