UI Toolkit Transitions have no Length (%) to Pixel (px) conversion. USS doesn't save units if their value is 0

This topic is about 2 bugs that are closely tied to each other.
I’ll use the Translate transformation as an example.

#1: UI transitions can’t handle changes in units.
Transition animations will be ignored if there is a difference in units between the initial and transitioned states.

Example transitions (:white_check_mark: runs transition animation, :x: does not):

:x: Default values => Length
image => image

:x: (Pixel, Pixel) => (Length, Length)
image => image

:x: Mirroring ONLY changing values
image => image

:white_check_mark: Exact Mirroring
image => image
or
image => image

So why is this a problem? Once you’ve identified what you want to transition, it should be fine once you’ve matched the units, right? That brings us to the second bug.

#2 USS doesn’t save the unit of a zero-value attribute.
If an attribute has a value of zero, USS assumes it is empty/ignored and doesn’t bother saving the unit between runtimes.

So you can set Translate to 0% 0% in the UI Builder or directly in the USS.

In either case, it will be AUTOMATICALLY reset to 0px 0px in the UI Builder and 0 0 in uss when you reload your project.

Before Reload:
image

.translatable  {
     translate: 0% 0%;
}

After Reload:
image

.translatable  {
     translate: 0 0;
}

So Unless I write the transition in c# instead, I can’t use Length for transitions? Let me know if I’m mistaken or this gets patched.
Thanks in advance!

1 Like