How to delay function Update execution?

I have a scene where a field of text is to fade in by raising the alpha channel over time. The effect works, but I would like to have it wait for a few seconds before it starts fading in. I know “yield.WaitForSeconds” doesn’t work in the update function, and I’ve read online about Coroutines, but I don’t really understand them. How could I incorporate this function into my code?

    private var myRenderer : Renderer;
    
    function Start () {
    myRenderer = renderer;
    yield WaitForSeconds(5);
    }
     
    function Update () {
    //yield WaitForSeconds(5);
    if (myRenderer.material.color.a < 255)
    myRenderer.material.color.a += 25.0*Time.deltaTime;
    }

I was also confused about coroutines, but is think the name is just confusing. The concept is quite simple.

In your update, call a function – aka coroutine – with a float variable like this:

function Update(){
     MyFunction(0.5);
}

function MyFunction(delay : float){
     yield WaitForSeconds(delay);
     // enter your code here
}

A coroutine is just another function. And other functions can happen over time, rather than right away.

The components of the Color class in unity go from 0.0 to 1.0, not 0 to 255. As for waiting, you can do it like this:

function Start () {
     myRenderer = renderer;
     yield WaitForSeconds(5);
     while (myRenderer.material.color.a < 1.0) {
          myRenderer.material.color.a += Time.deltaTime / 2.0;
          yield;
     }
     myRenderer.material.color.a = 1.0;
}

Assuming color.a starts at 0.0, this will take 2.0 seconds to fade it up once the 5 second wait is over.