I have a basic fading coroutine that is used to fade a black GUITexture to Color.clear using Lerp.Color. The coroutine has a FadeSpeed variable to control the speed of the fade. However, for some reason the fade is occurring much more quickly than the FadeSpeed I have entered. That is, Color.clear (0, 0, 0, 0) is reached before t has reached 1.
Any help would be great.
private float t = 0;
void Awake()
{
// Note, Pixel inset used for pixel adjustments for size and position.
guiTexture.pixelInset = new Rect(0f, 0f, Screen.width, Screen.height);
}
void Start()
{
StartCoroutine(FadeToClear());
}
IEnumerator FadeToClear()
{
while (t < 1)
{
t += Time.deltaTime * (1.0f / FadeSpeed);
guiTexture.color = Color.Lerp(guiTexture.color, Color.clear, t);
yield return new WaitForEndOfFrame();
}
}