Search Unity

Official Announcing USS transition

Discussion in 'UI Toolkit' started by SimonDufour, Nov 26, 2021.

  1. SimonDufour

    SimonDufour

    Unity Technologies

    Joined:
    Jun 30, 2020
    Posts:
    574
    You may have seen that we recently added the transform properties and that these are more optimal for animations. This is put to the test with our new feature: USS Transitions!


    These transitions are optimizing the creation of rich, interactive UIs based on UI Toolkit. The USS transitions, based on the CSS equivalent, offer a simple way to do some basic animations by offering a transition whenever the style changes. When set up, these are triggered regardless of the source of the change, whether it is a class added, a pseudo style change was applied or event the inline change was made in C#.

    transition example.gif

    Here is a quick tutorial going over all the step to apply a transition in the UI builder.
    https://forum.unity.com/threads/quick-transition-tutorial.1203841/

    This is a large feature, because it touches every USS property. We may have worked really hard to provide as much functionality as possible from day one, with as few exceptions as possible.

    We have three different categories of property:
    • Fully animatable,
    • discrete animation only, and
    • not animatable

    The
    fully animatable 
    implies that the value will transition gradually from the previous value to the final one, at a speed that follows the easing function and transition duration. The
    discrete animation
    allows for changing a parameter, but in a single step from the initial value to the end value. This is usually a property that does not have an "in between" state, or the one that would be really difficult to animate, like the text alignment. Finally,
    not animatable
    do not support the transition framework at all. We think most frequent use cases are covered by the current implementation.

    So here is what we are supporting:

    *drummroll*


    Fully animatable:
    bottom; left; right; top;
    color; background-color;
    opacity;
    flex; flex-basis; flex-grow; flex-shrink;
    rotate; scale; translate; transform-origin;
    height; width; max-height; min-height; max-width; min-width;
    border-width; border-top-width; border-right-width; border-left-width; border-bottom-width;
    border-radius; border-top-right-radius; border-top-left-radius; border-bottom-left-radius; border-bottom; -right-radius;
    border-color; border-top-color; border-right-color; border-left-color; border-bottom-color;
    margin; margin-bottom; margin-left; margin-right; margin-top;
    padding; padding-bottom; padding-left; padding-right; padding-top;
    letter-spacing; word-spacing; -unity-paragraph-spacing;
    -unity-background-image-tint-color;
    -unity-text-outline; -unity-text-outline-color; -unity-text-outline-width;
    text-shadow;
    -unity-slice-bottom; -unity-slice-left; -unity-slice-right; -unity-slice-top;


    Discrete animation:
    visibility;
    background-image;
    align-content align-items;
    display;
    flex-direction flex-wrap;
    font-size;
    justify-content;
    overflow;
    position;
    text-overflow;
    -unity-font-definition;
    -unity-font;
    -unity-background-scale-mode;
    -unity-font-style;
    -unity-overflow-clip-box;
    -unity-text-align;
    -unity-text-overflow-position;
    white-space;

    not animatable:
    cursor;
    transition; transition-delay; transition-duration; transition-property; transition-timing-function;

    *take a deep breath*

    In addition to that, we support many easing functions, variable transition durations and a configurable transition delay. This allows for modifying the look and feel of the transition as well as adjusting the sequence in which the transitions occur. Using the easing functions allows the discrete animation to be triggered at the beginning, the end or even in the middle of the transition.


    There are so many new details with these features that the documentation needs to catch up. We still want to allow those who are familiar with the CSS equivalent to start using this new tool as soon as possible!

    Under the hood is an event system that enables a lot of possibilities, that would be detailed in a future post.

    Finally, we are still improving the performance and reducing the cost of transitioning for most frequently used properties.in futures version of Unity.
     
    Last edited: Nov 26, 2021
  2. RichardWepner

    RichardWepner

    Joined:
    May 29, 2013
    Posts:
    33
    Hello dear developer,

    is it / will it be possible to use these transitions already ingame (not only in the editor)? I would assume it to be possible, but it's better to be safe than sorry.
    If so, what are / will be the requirements for the corresponding packages and the Unity version? (I have a faint memory of some UIToolkit features requiring the newest Unity alpha version at that time, but I could also be mistaken in this regard.)

    I'm looking forward for a response, since transitions seem to me to be a very important feature in order to have nice ingame UIs (-> e. g. for button transitions).

    Richard
     
  3. SimonDufour

    SimonDufour

    Unity Technologies

    Joined:
    Jun 30, 2020
    Posts:
    574
    Yes. They are fully available wherever you can use UI Toolkit.

    You need Unity 2021.2 or newer. There is no preview package needed anymore for the runtime part of unity.
     
    samanabo likes this.
  4. TeorikDeli

    TeorikDeli

    Joined:
    Apr 6, 2014
    Posts:
    150
    Hi @SimonDufour , will there (or is there) be a transitionend like events (run, start, cancel, end) for UI Toolkit? It'd be nice if we can track transitions with events (especially end event). I think we can use coroutines and reading visualelement's style.transitionDuration + style.transitionDelay, but this could easily cause some problems.

    And, also, will there be a custom transitionTimingFunction (like cubic-bezier, steps in css; most likely with an AnimationCurve).
     
  5. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    700
    We have all of those events already! You can find them all in the API documentation for Unity 2021.2+ (here's the one for TransitionEndEvent for example).

    There are many timing functions already, if you use the UI Builder you can see a complete list of them :)
     
    TeorikDeli likes this.
  6. TeorikDeli

    TeorikDeli

    Joined:
    Apr 6, 2014
    Posts:
    150
    Well, @JuliaP_Unity , I have to dig more carefully in the documentation :D Thank you!

    About the timing functions, I know there are many defined functions (haven't tried them all :oops:), but I believe the custom ones could make a big difference. For example, using an AnimationCurve as a timing function would give more unique possibilities. Don't get me wrong, 23 EasingMode is not less; but I believe the transitions/animations needs more freedom on timing to make them more unique/tasty. :)
     
    Yecats likes this.
  7. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    700
    Oh I had misread your original question, sorry about that! :oops:
    For the moment, there's no plan to make custom curves, but I'll bring this feedback to the group!
     
    TeorikDeli likes this.
  8. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    1,261
    This should really be stickied so that its more visible, wasn't easy to find out about this. Great work on this guys.
     
    KamilCSPS likes this.
  9. KamilCSPS

    KamilCSPS

    Joined:
    May 21, 2020
    Posts:
    448
    Wow, you're right @Chris-Trueman... completely missed it! It's a huge feature and I wasn't even aware it was released!

    Great job UITK Team!
     
    Chris-Trueman likes this.
  10. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    700
    For the record, this post is pinned to the top! We probably have too many pinned posts now though so I'll bring that up with the team :cool:
     
    Chris-Trueman likes this.
  11. TeorikDeli

    TeorikDeli

    Joined:
    Apr 6, 2014
    Posts:
    150
    I think Unity has some documentation problem here :oops: There is no mention in the Manual for USS transitions (at least I couldn't find in 2021.2 & 2022.2 manuals) and the Scripting API has no hierarchy, so it's usually not easy to find things (grouping events, elements, etc. would be much more easier to find anything, at least in my opinion). :rolleyes:
     
  12. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    700
    We're aware and actively working on the manual for all new features! :cool:
     
  13. useraccount1

    useraccount1

    Joined:
    Mar 31, 2018
    Posts:
    275
    Is unity aware of some bugs related to transitions?

    Here I'm rotating a picture and changing its color.


    Here I'm changing the picture from a normal version to one with a yellow border.
     
  14. Onigiri

    Onigiri

    Joined:
    Aug 10, 2014
    Posts:
    484
    Regarding first one it's not a bug. You are hovering corner of element and when it's rotating cursor appears out of boundary so :hover selector is not true anymore and then the next corner is going under cursor and :hover is true again and so on
     
    mariandev likes this.
  15. useraccount1

    useraccount1

    Joined:
    Mar 31, 2018
    Posts:
    275
    It's also worth noting that this "not a bug" is somehow working almost perfectly on a web browser. It's impossible to reproduce the same behavior the unity's UI Toolkit gives out.

     
  16. StripeGuy

    StripeGuy

    Joined:
    Dec 30, 2016
    Posts:
    52
    Does anybody know how to animate a "slide-out" menu? Would you make a css (uss) class with that animation, then somehow add it to that UI Element by script on button press?
     
  17. SimonDufour

    SimonDufour

    Unity Technologies

    Joined:
    Jun 30, 2020
    Posts:
    574
    I tested firefox and chrome and I found different oddities with both :) But their behavior is definitely different as they do not calculate the style as long as the mouse does not move again or that another event trigger a refresh of the styles.

    Something that could help you would be to override the ContainsPoint method to be set based on a measure of the distance from the center of the element. This make the hover constant during the rotation and prevent any jitter. You could probably also return the last result while the transition is running using transition events.


    You would require more than just a uss class to manage the button press and set a few states, but it is absolutely doable.
    Assuming that the element could be behind something on the first frame, I would animate the translate by left shifting the menu by 120% using two style:

    Menu : always on the element, set the Transition-property and transition duration here
    MenuHidden with translate -100% , 0

    When the button is pressed, you then just remove the MenuHidden class from your visual element.

    If you are targeting greatly varying aspect ratio, I sometime add a shorter transition on the opacity to hide the initial position of the element.
     
  18. StripeGuy

    StripeGuy

    Joined:
    Dec 30, 2016
    Posts:
    52
    Merci Simon! Good to see another french-canadian on here :p

    I tried your method of having 2 classes on the element and removing the "hidden" class on button press, but the "menu" just instantly appears and doesn't animate for some reason.


    Edit: Nevermind. I got it working! I used Percentage instead of pixels, but on the original " menu" it was set to 0px instead of 0%. I guess Unity couldn't do that math, haha.

    I guess the only question I would have is what is the best way to "toggle" it with the same button? Is there a way to check if a class is on the element?
     
    Last edited: Feb 8, 2022
  19. SimonDufour

    SimonDufour

    Unity Technologies

    Joined:
    Jun 30, 2020
    Posts:
    574
    :| this should work. I tested it myself a few times, and we do handle 0px as 0% and vice versa for both the initial or final style. If you are able to reproduce this, please report a bug in unity with a repro project because there is something I seem to ignore.


    GetClasses could be helpfull to test if the class is set and change the state accordingly, but I just saw that there is a ToggleInClassList in the API. I personally never used it, but I think it should do what you are looking for!
     
  20. StripeGuy

    StripeGuy

    Joined:
    Dec 30, 2016
    Posts:
    52
    Hmm, then it must have been something else I messed up but fixed. I tried a few different things when it wasn't working, and that's one of the things that I fixed. Oh well, it worked in the end :)

    Thanks so much! That worked wonderfully. Just called a function with these in it:
    Code (CSharp):
    1. VisualElement.ToggleInClassList("menu-show")
    2. VisualElement.ToggleInClassList("menu-hide")
    Then I just created those classes in the "builder" and assigned the appropriate animations/translations to the them. I add only the "menu-hide" class to menu element, and that's it. The function simply "toggles" between the classes when it gets called.
     
    SimonDufour likes this.
  21. SimonDufour

    SimonDufour

    Unity Technologies

    Joined:
    Jun 30, 2020
    Posts:
    574
    Usually, peoples tend to forgot that inline style override the value of the class. When you set the style directly in the UI Builder, it is an inline style, so toggling the class never change the value.
     
  22. StripeGuy

    StripeGuy

    Joined:
    Dec 30, 2016
    Posts:
    52
    So it happened again that it wasn't working, then noticed it went back to px instead of %. Looks like whenever I shutdown unity and restart it, it goes back to pixels (that one element class only - ".showmenu"). The other stays at %. And when it's at 0px (translation Y btw), it doesn't animate. I have to put it back to percentage then it works. I can reproduce it every time.

    I am using Unity 2021.2.8f1. Where should I report this bug?

    Edit: This is a bigger issue than I thought. It's an issue where it doesn't put the "%" in the .uss class file of ANY property that is at "0", so when you restart unity and it sets all the values from your uss file, it won't know it's a percentage, so it defaults to px. And it seems to only not animate properly if it's "100% -> 0px", and works if it's "0px -> 100%" for example. Anyway, I submitted the bug and we'll see if they fix it, cause it's an absolute pain to go in all my animation to change it to % everytime I open my project to work on it.
     
    Last edited: Feb 16, 2022
  23. SimonDufour

    SimonDufour

    Unity Technologies

    Joined:
    Jun 30, 2020
    Posts:
    574
    In the editor, in look for the menu Help->Report a bug.

    Please include as much information as possible, a small/simple repro project if possible
     
  24. KamilCSPS

    KamilCSPS

    Joined:
    May 21, 2020
    Posts:
    448
    Salut Simon,

    The transitions work beautifully however I am hitting a wall trying to programmatically define the end value for a transition.

    In short, I toggle a 'hover-active' class in C# on a visualElement. The class only has a width value changed. That works, no issues.

    However, I want in C# to dynamically change that width before triggering the animation (or at start, whatever works). Is it possible to change the target value that a transition will animate to by code and not in USS? Right now, setting the width before just changes the width directly without doing any transition.

    Code (CSharp):
    1.  
    2. m_backBtnBG.style.width = new Length(500, LengthUnit.Pixel);
    3. m_backBtnBG.style.transitionDelay = new List<TimeValue>() { new TimeValue(0, TimeUnit.Millisecond) };
    4. m_backBtnBG.style.transitionProperty = new List<StylePropertyName>() {  new StylePropertyName("width") };
    5. m_backBtnBG.style.transitionDuration = new List<TimeValue>() { new TimeValue(500, TimeUnit.Millisecond) };
    6. m_backBtnBG.AddToClassList("hover-active");
    If not, how should we tackle this?

    EDIT: Disregard.
    You have to make sure the value in the class (width) is actually set (not unset) first and then you can define the width. Doh.
     
    Last edited: Feb 11, 2022
    SimonDufour likes this.
  25. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    767
    This is a really terrific feature, thank you so much, I was able to bring my UI to glorious animation with very little code.

    The only thing missing is the ability to loop animations. For example for pulsing buttons.
     
  26. uMathieu

    uMathieu

    Unity Technologies

    Joined:
    Jun 6, 2017
    Posts:
    398
    @goldbug : Indeed, for that you currently need to hook to TransitionEndEvent and change styles either inline or by adding/removing css classes. Definitely not ideal.
     
  27. viktorcode

    viktorcode

    Joined:
    Jun 30, 2020
    Posts:
    23
    How do I temporarily disable a transition on an element?I tried using `element.RemoveFromClassList("transition_class");` and then later `element.AddToClassList("transition_class");`. Transitions do get disabled, but they fail to work after 'm adding the class back, despite the class being actually present on the element which can be seen in the debugger.

    Any other (working) way disabling and re-enabling transitions?
     
  28. SimonDufour

    SimonDufour

    Unity Technologies

    Joined:
    Jun 30, 2020
    Posts:
    574
    You could use both the as class toggling the style or the inline style to activate the transition on the element.

    Timing is usually the key problem for this, and it is hard to pinpoint the issue without having more details. I would require more details to know what is going on, what are the style involved, etc. to better see how I can help you solve this: You could start another thread (because I think it could easily have a few long post with the code examples) or simply report a bug in the editor to have someone investigating this more in details.
     
  29. viktorcode

    viktorcode

    Joined:
    Jun 30, 2020
    Posts:
    23
    My issue is the transition is not triggered by changing inline style after I removed the class containing the transition and then added it back. Maybe I should wait a bit after adding the class back before I try to trigger the transition from changing inline style property?

    Can't test more right now as I borked my code.
     
  30. SimonDufour

    SimonDufour

    Unity Technologies

    Joined:
    Jun 30, 2020
    Posts:
    574
    Waiting/adding a delay will most certainly solve the issue.

    When modifying the inline style, the code check for the currently resolved value for transition, but if you change a style, the style will only be resolved and applied just before the LateUpdate phase, so at the moment where you change the inline style there is no transition to apply.
     
  31. viktorcode

    viktorcode

    Joined:
    Jun 30, 2020
    Posts:
    23
    Thank you, the following works:
    1. remove transition containing class from element
    2. do style changes I don't want animated
    3. add the class back to the element
    4. wait for next frame
    5. do style changes that should be animated
    So, item 4 was necessary.
     
    SimonDufour likes this.
  32. BilginSahin

    BilginSahin

    Joined:
    Jul 2, 2012
    Posts:
    48
    can anyone make a simple video how to make animations? :(
     
    Molder likes this.
  33. Smolty

    Smolty

    Joined:
    Nov 8, 2016
    Posts:
    17
    Wanted to ask if it's intentional that we cannot use the transition property with ID selectors or if it's a bug? (Unity 2021.3.3f1)

    Toggeling the .animate class on #element won't work, nothing happens:
    Code (CSharp):
    1. #element {
    2.     opacity: 0;
    3.     transition-property: opacity;
    4.     transition-duration: 1s;
    5. }
    6.  
    7. .animate {
    8.     opacity: 1;
    9. }
    While toggeling .animate on .element will work as intended:
    Code (CSharp):
    1. .element {
    2.     opacity: 0;
    3.     transition-property: opacity;
    4.     transition-duration: 1s;
    5. }
    6.  
    7. .animate {
    8.     opacity: 1;
    9. }
    I've already tripped over this a few times, wondering why an animation didn't want to work as I like to use ID selectors for elements that only exist once and are unique.

    Thanks
     
  34. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    700
    This comes down to selector specificity (you can read about it in our documentation in the "Selector specificity" section). since name selectors are more specific than class selectors,
    #element
    will always take precedence over any class you add, so that's why it only works when you're using
    .element
    and another class for triggering transitions.

    Hope this helps!
     
    Smolty and SimonDufour like this.
  35. Smolty

    Smolty

    Joined:
    Nov 8, 2016
    Posts:
    17
    Thanks for the reminder and explanation, I somehow skipped the whole selector specificity when I thought about why it didn't work :) It does make sense.
     
    JuliaP_Unity likes this.
  36. BBB_brunoma

    BBB_brunoma

    Joined:
    Jan 10, 2017
    Posts:
    21
    Is there a bug when animating the height property via ToggleInClassList? It seems like height gets treated as a discrete animation property in this case (Unity 2021.3.0f1)
     
    ChickenHugs likes this.
  37. dynamicbutter

    dynamicbutter

    Joined:
    Jun 11, 2021
    Posts:
    63
    Great feature!

    Here's some c# code that does the slide-out thing that @StripeGuy asked about earlier in the thread. There were some nuances to doing this that were hard for me using uss and I found the c# easier to work with. You can just paste these functions into a script that contains your UiDocuments. Shouldn't need any additional uss. The main functions being demonstrated are PanelTransitionLeftToRight and PanelTransitionRightToLeft.

    Code (CSharp):
    1.  
    2. // Assuming the startPanel is visible and we want to transition to the endPanel from left to right
    3. void PanelTransitionLeftToRight(UiDocument startPanel, UiDocument endPanel, float duration)
    4. {
    5.     HidePanel(endPanel);
    6.     PanelRight(endPanel, 0f);
    7.     PanelLeft(startPanel, duration);
    8.     ShowPanel(endPanel);
    9.     PanelCenter(endPanel, duration);
    10. }
    11.  
    12. // Assuming the startPanel is visible and we want to transition to the endPanel from right to left
    13. void PanelTransitionRightToLeft(UiDocument startPanel, UiDocument endPanel, float duration)
    14. {
    15.     HidePanel(endPanel);
    16.     PanelLeft(endPanel, 0f);
    17.     PanelRight(startPanel, duration);
    18.     ShowPanel(endPanel);
    19.     PanelCenter(endPanel, duration);
    20. }
    21.  
    22. void HidePanel(UiDocument panel)
    23. {
    24.     panel.rootVisualElement.style.display = DisplayStyle.None;
    25. }
    26.  
    27. void ShowPanel(UiDocument panel)
    28. {
    29.     panel.rootVisualElement.style.display = DisplayStyle.Flex;
    30. }
    31.  
    32. void SetAnimationTransitionDuration(UiDocument panel, float seconds)
    33. {
    34.     panel.rootVisualElement.style.transitionDuration = new List<TimeValue>() { new TimeValue(seconds, TimeUnit.Second) };
    35. }
    36.  
    37. void SetAnimationTransitionPosition(UiDocument panel, float x, float y)
    38. {
    39.     panel.rootVisualElement.style.translate =
    40.         new StyleTranslate(new Translate(new Length(x, LengthUnit.Percent), new Length(y, LengthUnit.Percent), 0));
    41. }
    42.  
    43. void PanelCenter(UiDocument panel, float duration)
    44. {
    45.     SetAnimationTransitionDuration(panel, duration);
    46.     SetAnimationTransitionPosition(panel, 0f, 0f);
    47. }
    48.  
    49. void PanelRight(UiDocument panel, float duration)
    50. {
    51.     SetAnimationTransitionDuration(panel, duration);
    52.     SetAnimationTransitionPosition(panel, 100f, 0f);
    53. }
    54.  
    55. void PanelLeft(UiDocument panel, float duration)
    56. {
    57.     SetAnimationTransitionDuration(panel, duration);
    58.     SetAnimationTransitionPosition(panel, -100f, 0f);
    59. }
    60.  
     
    Last edited: Aug 18, 2022
    jGate99 likes this.
  38. KirillVorotov

    KirillVorotov

    Joined:
    Mar 26, 2013
    Posts:
    2
    Hi. Is it possible to create custom easing functions for transitions?
     
  39. SimonDufour

    SimonDufour

    Unity Technologies

    Joined:
    Jun 30, 2020
    Posts:
    574
    No
     
  40. jakob-leitner

    jakob-leitner

    Joined:
    Nov 11, 2020
    Posts:
    18
    Hello, I keep getting this error when using uss animations/transitions.

    upload_2022-9-29_14-3-44.png


    Is this a bug or am I doing something wrong?
     
  41. SimonDufour

    SimonDufour

    Unity Technologies

    Joined:
    Jun 30, 2020
    Posts:
    574
    Can you file a bug with this so that we have more context on what exactly you are doing?
     
  42. Singtaa

    Singtaa

    Joined:
    Dec 14, 2010
    Posts:
    492
  43. jakob-leitner

    jakob-leitner

    Joined:
    Nov 11, 2020
    Posts:
    18
    @SimonDufour @Singtaa I'll try that workaround right away :) And yes, the link you provided seems to describe exactly the same issue (IssueID: UUM-13155).
    (UnityVersion: 2022.1.13f1)
     
    Singtaa likes this.
  44. azmi_unity

    azmi_unity

    Joined:
    Dec 13, 2020
    Posts:
    62
    Is there a way to have a transition when I remove a class?

    Like for tab buttons, when I'm selecting between tabs I add a "selected" class. There's a transition when it's added but not when it's removed.
     
  45. TeorikDeli

    TeorikDeli

    Joined:
    Apr 6, 2014
    Posts:
    150
    It is just like CSS. If you put your transition property on the tab's itself, it'll be transitioned when you add or removed class.

    Code (CSharp):
    1. .tab {
    2.   transition: 0.5s;
    3.   color: red;
    4. }
    5. .selected {
    6.   color:black;
    7. }
     
    azmi_unity likes this.
  46. TeorikDeli

    TeorikDeli

    Joined:
    Apr 6, 2014
    Posts:
    150
    Hi @SimonDufour , is there a way to use transitions for CustomStyleProperties? I successfully added skewing a rounded box (which I will share in this thread) and I am trying to add transition to skew properties (added --skew-x and --skew-y CSS properties). I don't want to use Coroutines, if there is a way in the UI Toolkit.
     
  47. azmi_unity

    azmi_unity

    Joined:
    Dec 13, 2020
    Posts:
    62
    Thanks! It is that simple.
     
    TeorikDeli likes this.
  48. SparkesRS

    SparkesRS

    Joined:
    Jan 11, 2024
    Posts:
    6
    Unfortunately it looks like in 2021.3 you can only have one selector with a transition running at a time. I wanted to transition between menus with 0.3s opacity fadeout and 1.2s for the menu to translate 100% off screen. If the opacity and translation are handled by different selectors and you add them at the same time, then nothing happens at all, as here:

    Code (CSharp):
    1. .hide-right-opacity {
    2.     opacity: 0;
    3.     transition-property: opacity;
    4.     transition-duration: 0.3s;
    5. }
    6.  
    7. .hide-right-translate{
    8.     translate: 100%, 0;
    9.     transition-property: translate;
    10.     transition-duration: 1.2s;
    11. }

    If you let both selectors handle both opacity and translation, then whichever is added last overrides the duration for both, as here:

    Code (CSharp):
    1. .hide-right-opacity {
    2.     opacity: 0;
    3.     transition-property: opacity, translate;
    4.     transition-duration: 0.3s;
    5. }
    6.  
    7. .hide-right-translate{
    8.     translate: 100%, 0;
    9.     transition-property: opacity, translate;
    10.     transition-duration: 1.2s;
    11. }
    I'll have to make a parent element for each individual effect I want running on separate transition durations it looks like.
     
  49. uMathieu

    uMathieu

    Unity Technologies

    Joined:
    Jun 6, 2017
    Posts:
    398
    You're right that as transition-property and transition-duration are style properties, they resolve to only 1 value, even if the transition-property value is a list. You can however, specify the transition-duration as a list as well
    Code (CSharp):
    1. .hide-right{
    2.     opacity: 0;
    3.     translate: 100%, 0;
    4.     transition-property: opacity, translate;
    5.     transition-duration: 0.3s, 1.2s;
    6. }