Search Unity

Using the state machine with UI Animation: how to do easings?

Discussion in 'Animation' started by Waarten, Feb 3, 2021.

  1. Waarten

    Waarten

    Joined:
    Aug 24, 2018
    Posts:
    38
    Hello,

    I got excited about the way Unity supports both a keyframed animation timeline and animation state transitions. This page on UI suggests that the same workflow is also suitable for UI animations.

    I'm setting up a simple button that changes size when hovering, just to test the system. It seems that the intended way of doing this is that I make an "animation" for the highlighted state (which is actually just a frame with one value). I can then edit transitions to tune the timing. This is fine and all, but I'm now lacking a vital part of snappy UI design: easings.

    My first thought was that I could animate a 'springy' effect into the first few frames of the animation corresponding to the highlighted state. But it seems that these animations _within_ the state are meant for continuous animations, not the transitions themselves.

    The transitions between states seem to only interpolate linearly.

    Of course I can make this "work" by firing a coroutine and setting the value manually.
    But I feel that I should first exploit the tools that Unity provides me. If I can, I'd rather keep the state machine and the inspector keyframe recording into my workflow.

    Any thoughts are very welcome, thanks in advance!
     
    ManuelKers likes this.
  2. Waarten

    Waarten

    Joined:
    Aug 24, 2018
    Posts:
    38
    Is there a moderator who wants to move this to the UI forum ("UGUI & TextMesh Pro")? I feel that I might have more luck there.

    Thanks!
     
  3. maewionn

    maewionn

    Joined:
    Jan 18, 2016
    Posts:
    38
    Bumping this sincce I am wondering the same thing.
    I mean, editing all the curves for each keyframe seems like an alternative, but how can we throw a simple easings curve on it?

    Oh, and Waarten, for UI, I can recommend dropping the whole aniamtion stuff and using LeanTween - should suffice for most purposes and has a really smooth workflow (the whole animation in 1 line of code)