1

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.

Pyreal
  • 207
  • 4
  • 13

1 Answers1

0

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.

Pyreal
  • 207
  • 4
  • 13