Search Issue Tracker
By Design
Votes
0
Found in [Package]
1.0.0-preview.14
Issue ID
1350951
Regression
No
[UI Toolkit] Visual Element flashes for a single frame when doing USS animations
How to reproduce:
1. Open the attached project's Scene labeled "SampleScene"
2. Enter the Play Mode
3. Observe the Game View
Expected result: Red square is not shown
Actual result: Red square flashes for a single frame
Reproducible with: 1.0.0-preview.14 (2021.1.15f1) (Square doesn't disappear instead), 2021.2.0b7, 2022.1.0a5
Not reproducible with: 1.0.0-preview.14 (2020.3.16f1)
Couldn't test with 2019.4.29f1 (UI Toolkit is not available), 2021.1.16f1, 2021.1.17f1 (unresolvable UI Toolkit errors)
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
- Memory leak when a lot of UI elements are spawned and despawned
- Warnings are not logged in the Console window when using external code analyzers
- Errors “TLS Allocator ALLOC_TEMP_TLS, underlying allocator ALLOC_TEMP_MAIN has unfreed allocations, size 288“ appear constantly when Prefab is open
- Crash on PPtr<Shader>::operator or NullException errors spammed in console when calling Dispose() on null GraphicsBuffer with baked Reflection Probes
- “EndRenderPass: Not inside a Renderpass” and other Render Graph errors in the Player when Render Graph is enabled and Overlay UI is used
Resolution Note:
There are some misunderstandings on how the UIDocument component works here, which is due to our lack of documentation, so apologies about that.
The UXML file won't be loaded by the UIDocument component until OnEnable runs on it, so trying to access the root during Start in the NewBehaviourScript component means you may not get the root of the cloned tree. We highly suggest using OnEnable on your component to guarantee the expected behavior.
In any case, when you wait for the end of the frame through your yield return statement, that means one frame will be drawn and that one frame can contain the cloned tree. Also if I understand correctly, you want to use a USS transition to move the square after the first frame, and the preferred way of moving something on screen like that would be to register a callback to the GeometryChangedEvent and change the position of the square in the callback. That guarantees the transition will kick in since the first layout will have the square in place and when the new position is set, it'll transition to it as expected.