1
\$\begingroup\$

I'm able to Lerp the color of a UI panel within the Update method. However I'd like to trigger behavior a single time when needed. If I put it in a method and call it it only changes for a brief time and doesn't fully complete. I could probably set a bool flag within the update method but that seems sloppy.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ A tweener like DoTween or a coroutine will work. Have you tried either? \$\endgroup\$
    – Sidar
    Commented Mar 11, 2019 at 18:48

1 Answer 1

0
\$\begingroup\$

Using a Coroutine gives the desired effect.

IEnumerator ChangeColorTest()
    {
        for (var i = lerpDuration; i >= 0; i -= 0.1f)
        {
            UIPanel.color = Color.Lerp(startColor, endColor, Time.time / lerpDuration);

            yield return new WaitForSeconds(0.1f);
        }
    }

I'd like the color transition to be smoother but this might be how Coroutines work.

\$\endgroup\$
1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .