dotween icon indicating copy to clipboard operation
dotween copied to clipboard

Use OnUpdate with no tweening

Open icutter opened this issue 2 years ago • 0 comments

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();
}

icutter avatar Feb 23 '23 19:02 icutter