UI Toolkit wait for end of transitions

Hi there,
I’m using UI Toolkit on Unity 2021.2.5f1 and I was wondering if there’s a way to await transitions in C#?
I’d like to be able to show a screen, wait for transitions to finish and then do something. Same thing for leaving a screen.

Is there a way to:

  • Query for elements with a transition duration and transition delay properties and await for that amount of time?
  • Get a variable from a USS file? (I can define that as a transition variable and then await for that amount of time)
  • Any other idea?

Ideally I don’t want to hardcode a duration in C# as that’s not designer friendly.

You can register a callback for the TransitionEndEvent onto the element for which the transition occurs.

2 Likes