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

Package: UI Toolkit

-

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)

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

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.