Text Mesh Scripting

We would like to use a Text Mesh to display a series of words which is highlighted one word at a time.

Any ideas on how this would be done?

My progress so far:

public var textA : String;
           textA += "Once upon a time" 
           textA += "there was a little girl.";

function Start() {
      var myTextMesh = (GetComponent(TextMesh) as TextMesh);
      myTextMesh.text = textA;
      renderer.material.SetColor("_Color", Color.red);


I appreciate your answer Eric5h5!

We could use it as a fallback technique. However what I was hoping for was for the full text to be on screen and then for each word to highlight as the voice over reads them.

For example all text would be blue and then as each word is read it would become red and then return to its original state.

Use an array of text, and loop through it with a delay after each addition:

var text = ["Once upon a time
", "there was a little girl."];
var delay = 1.0;

function Start() {
    var myTextMesh = (GetComponent(TextMesh) as TextMesh);
    renderer.material.color = Color.red;
    myTextMesh.text = "";
    for (i = 0; i < text.Length; i++) {
        myTextMesh.text += text*;*
 *yield WaitForSeconds(delay);*