Demigiant / dotween

A Unity C# animation engine. HOTween v2
http://dotween.demigiant.com
Other
2.34k stars 351 forks source link

Use OnUpdate with no tweening #626

Open ironcutter24 opened 1 year ago

ironcutter24 commented 1 year ago

Is it possible to use OnUpdate() for a fixed amount of time, without any real tweening going on? I think this would look cleaner than most alternatives.

IEnumerator _Fooroutine()
{
    // What I'd like to do:

    var tween = DOWait(1.2f)
        .OnUpdate(()=>(/* Do stuff*/));
    yield return tween.WaitForCompletion();

    // What I usually end up doing:

    float waitTimer = 1.2f;
    while (waitTimer > 0f)
    {
        // Do stuff

        waitTimer -= Time.deltaTime;
        yield return null;
    }

    // Or

    var timer = TimerManager.SetNew(1.2f);
    while (!timer.IsExpired)
    {
        // Do stuff
        yield return null;
    }
    timer.Release();
}