I have found it rather difficult to find a solution to this in the Unity documents.
Color.Lerp(Color a, Color b, float t)
is a function that gradually changes a color according to a step t, giving it the final value of the Color b.
How do I Lerp between multiple colors one after another?
Answer
Let _colors be an array of colors let LENGHT be the number of colors in the array let t be the 0..1 float value
float scaledTime = t * (float) (LENGHT - 1);
Color oldColor = _colors[(int) scaledTime];
Color newColor = _colors[(int) (scaledTime + 1f)];
float newT = scaledTime - Mathf.Round(scaledTime);
finally you can use Lerp
Color.Lerp(oldColor, newColor, newT)
No comments:
Post a Comment