Getting an error when trying to yield

I am trying to make a make shift credits screen that replaces a texture every five seconds to show what a new person was involved in. Example:

if (who == 0)
{
    guiTexture.texture = tex1;
    yield WaitForSeconds(5);
    who = 1;
}
if (who == 1)
{
    guiTexture.texture = tex2;
    yield WaitForSeconds(5);
}

I get an error saying: Update() can not be a coroutine.

Any suggestions to fix this? Thanks in advance!

Checkout the following answer:

http://answers.unity3d.com/questions/48525/what-function-can-be-a-coroutine

Update is called around 50-70 times a second. You can't suspend it for 5 sec. Just use a seperate coroutine for that. Start() can be a coroutine, use that:

function Start()
{
    guiTexture.texture = tex1;
    yield WaitForSeconds(5);
    guiTexture.texture = tex2;
    yield WaitForSeconds(5);
    // ...
}

or in C#

IEnumerator Start()
{
    guiTexture.texture = tex1;
    yield return new WaitForSeconds(5.0f);
    guiTexture.texture = tex2;
    yield return new WaitForSeconds(5.0f);
    // ...
}


If you don't want to start the coroutine at the beginning use a seperate function

function ShowCredits()
{
    guiTexture.texture = tex1;
    yield WaitForSeconds(5);
    guiTexture.texture = tex2;
    yield WaitForSeconds(5);
    // ...
}

// Somewhere trigger ShowCredits
ShowCredits();

In C# you have to start a coroutine explicitly with StartCoroutine

StartCoroutine(ShowCredits());