IEnumerator ChangeColorAfterTime( float delayTime)
{
Color currentcolor;
Color nextcolor;
while (true) {
currentcolor = (Color)ColorsList [UnityEngine.Random.Range (0, Colors.Length)];
nextcolor = (Color)ColorsList [UnityEngine.Random.Range (0, Colors.Length)];
gameObject.GetComponent<SpriteRenderer> ().color = Color.Lerp (currentcolor, nextcolor, delayTime);
}
}
yield return new WaitForSeconds (delayTime);
}
}
I have a list of Colors and what i want is to continuously Lerp the color of gameObject from current to nextColor and i want this to happen in time delayTime , currently what happens is it changes its color from current to next in delay time but it doesn’t Lerp it changes from current to next after the specified time is over