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

LeanTween vs Mecanim for the New UI

Discussion in 'UGUI & TextMesh Pro' started by cl9-2, Dec 16, 2014.

  1. cl9-2

    cl9-2

    Joined:
    May 31, 2013
    Posts:
    417
    Hello,

    I'm currently using LeanTween for the new UI, and everything seems to be working very well. Here is example of code that I use to fade in a screen over 2 seconds.

    Code (CSharp):
    1.     LeanTween.value(canvasGroup.gameObject, 0f, 1f, 2f ).setOnUpdate((float alpha)=>{
    2.             canvasGroup.alpha = alpha;
    3.         }
    4.         );
    Is anyone else using tweening? If so, do you prefer tweening or Mecanim?

    Thanks!
     
  2. Raimis

    Raimis

    Joined:
    Aug 27, 2014
    Posts:
    160
    We use DOTween so far. Not sure which of the two is better, but we decided to ditch unity native animation since it's hard to use for small "transition-in" type of things. Especially if content is dynamically built.
     
    cl9-2 likes this.
  3. cl9-2

    cl9-2

    Joined:
    May 31, 2013
    Posts:
    417
    I didn't consider the limitations you've mentioned concerning Unity native animation. This is good to know.
     
  4. Raimis

    Raimis

    Joined:
    Aug 27, 2014
    Posts:
    160
    This might come from the fact that we don't know full power of it (or maybe how to use it at all), but after spending few looking for the solution that would allow us to maintain flexibility using unity animations on dynamic content - we failed.
     
  5. Levr01

    Levr01

    Joined:
    Jun 6, 2017
    Posts:
    26
    DOTween eats very more FPS. 400 FPS drops to 100 with DOTween
     
  6. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    1,075
    @Levr01 Are you sure about the performance hit? Isn't it because you start animating alpha values which causes the drop in the frame rate maybe? It is hard to believe that this little peace of math has such a big performance impact.

    I remember that I also used DOTween in an old project.
    Now I am using Easing Functions by C.J. Kimberlin combined with some self made animation logic.

    I also rarely use Unity's animations because it feels too complex for a small transition like fade or move in / out. I also have a system in my current project where everything (actually only UI Screens) is created through prefabs via code and the transitions between the screens are made with code, not with unities animations.
     
  7. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,523
    Some of the best optimization tips for Unity UI contains some useful advice. #7 is a reminder that Mecanim Animators dirty their elements every frame, even if they're not doing anything. If performance is an issue, it may be better to use a custom tween/easing function like Hosnkobf or the legacy Animation component with a non-looping clip.
     
    NateReese77 likes this.