Search code examples
c#unity-game-engineleantween

how to keep track of Lean Tween function?


I want to know the time left to complete the animation as I am using unity asset Lean Tween to scale down my time bar, so when 5 seconds are left till the time run out I want to play sound of closing time. I was able to know when the animation is gonna end LeanTween.scaleX(timebar.gameObject, 1f, time).setOnComplete(this.Gameover) but how i can a get time left to complete? I have looked through documentation but didn't find anything useful.


Solution

  • Every LeanTween function returns an instance of LtDescr class. This class has access to variable of animation and methods that can control it. You can get total time by time and passed time by passed. Remained time equal to time-passed.

    LtDescr animation = LeanTween.scaleX(timebar.gameObject, 1f, time).setOnComplete(this.Gameover);
    var remainedTime = animation.time - animation.passed;