Basic screen fader fading too quickly

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();
        } 
    }

The problem is that you are updating the start position of your Lerp() each frame. You want to hold the start position constant when you use Lerp() this way (with a ‘t’ value that goes from 0.0 to 1.0). Try this:

IEnumerator FadeToClear()
{
    Color startColor = guiTexture.color;
    while (t < 1)
    {
        t += Time.deltaTime * (1.0f / FadeSpeed);

        guiTexture.color = Color.Lerp(startColor, Color.clear, t);

        yield return null;
    } 
}

Also you can use ‘yield return null’ to execute once each frame;