Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug Ui builder breaks animation transition

Discussion in 'UI Toolkit' started by manuelgoellnitz, Nov 5, 2021.

  1. manuelgoellnitz

    manuelgoellnitz

    Joined:
    Feb 15, 2017
    Posts:
    364
    When you have a transition animation like this:
    Code (CSharp):
    1. .animateWidth {
    2.     width: 0%;
    3.     transition-property: width;
    4.     transition-duration: 250ms;
    5. }
    6.  
    7. *:hover > .animateWidth {
    8.     width: 100%;
    9.     transition-property: width;
    10.     transition-duration: 250ms;
    11. }
    Which animates the width of an element on hover from 0% to 100%, then it works fine until the uibuilder writes the uss file again.
    Then "width: 0%;" becomes "width: 0;"
    And now the transition animation only works the first time from 0 to 100%.
    the 100% to 0 is done instant and all the following time, to.
    When I manually edit the uss file and add the "%" again the transistion animation works every time.

    And another annoying thing:
    When setting the transition-duration in the uibuilder to "0.25" seconds, after saving the file with it, it says "25" seconds...

    I am using Unity 2021.2.0
     
  2. SimonDufour

    SimonDufour

    Unity Technologies

    Joined:
    Jun 30, 2020
    Posts:
    515
    Hi!

    While it may look like 0px and 0% should produce a similar layout, transitioning between different units is "undefined" in the css specification. Keeping the unit in the uss is therefore the best approach.

    Can you fill two bug for the UI builder?
    • Width percentage is not preserved when editing uss with the Ui builder.
    • Wrong value is display for the transition-duration in the uibuilder ("0.25" get parsed as 25 seconds)
    Do you need help with filling the bugs?
     
  3. uMathieu

    uMathieu

    Unity Technologies

    Joined:
    Jun 6, 2017
    Posts:
    384
    > When setting the transition-duration in the uibuilder to "0.25" seconds, after saving the file with it, it says "25" seconds...

    I agree this is a real annoyance. Maybe this happens because of different locale settings. I got bit by this a few times using a French system where I need to input 0,25 instead of 0.25. Can you confirm if that's what happening? In any case, the builder should probably handle both, or ignore locale when parsing.
     
  4. manuelgoellnitz

    manuelgoellnitz

    Joined:
    Feb 15, 2017
    Posts:
    364
    Hm when I write 0.25 it is immediatelly set to 25. When I write 0,25 the same happens.
     
  5. Midiphony-panda

    Midiphony-panda

    Joined:
    Feb 10, 2020
    Posts:
    234
    I always thought we couldn't set the transition durations using floats in UIBuilder, and that we had to use ints + switch units accordingly :D

    If I set 0.25s, the value isn't changed. If I set 0,25s, 25 seconds are set.

    I'm also on a French system ^^"
     
  6. manuelgoellnitz

    manuelgoellnitz

    Joined:
    Feb 15, 2017
    Posts:
    364
    In unity float is the norm for nearly everything. So I thought it works here also. And it does. Only the UIBuilder does not.
     
  7. Onigiri

    Onigiri

    Joined:
    Aug 10, 2014
    Posts:
    410
    SimonDufour likes this.
  8. manuelgoellnitz

    manuelgoellnitz

    Joined:
    Feb 15, 2017
    Posts:
    364
    Even when use a variable for the 0%, the %-sign is removed. That is really annoying...
     
  9. manuelgoellnitz

    manuelgoellnitz

    Joined:
    Feb 15, 2017
    Posts:
    364
    Oh I overread that.
    (Case 1380049) here is the case
     
  10. Windwalk_Rosco

    Windwalk_Rosco

    Joined:
    Aug 10, 2020
    Posts:
    20
    This bug is still present in version 2021.3.8f1 and is very frustrating. The case posted above is marked as resolved for this version but still persists. Is there another case for this issue?
     
  11. JulianNeil

    JulianNeil

    Joined:
    Jun 27, 2022
    Posts:
    56
    I'm still having trouble with transitions on attributes with % values. "0%" is replaced with 0 in USS files in version 2021.3.15f1 . Is there any workaround to prevent this? Its a bit tedious to have to correct my uss every time I modify things in the editor. I tried using -0% and 0.0% and -0.0% but it still saves as 0.
     
  12. manuelgoellnitz

    manuelgoellnitz

    Joined:
    Feb 15, 2017
    Posts:
    364
    I made a USS-Variable. This way I only need to fix one line.
     
    JulianNeil likes this.
  13. JulianNeil

    JulianNeil

    Joined:
    Jun 27, 2022
    Posts:
    56
    Good idea Manuel. That will make things a bit easier.