Change all material elements of one object on mouse over.

So far the script below is great but when one object has several materiel elements its only changing element [0] so no red on mouse enter as other materials remain above and visible.

I don’t ask usually but I can not work this one out, basically rewrite the render so it changes all materials to red on mouse enter and return to default on mouse exit.
var initialColor : Color;
var textObject : GUIText;

function Start() { initialColor = renderer.material.color; 
                  textObject.text = "";} 
function OnMouseOver() { renderer.material.color =;
                        textObject.text =; } 

function OnMouseExit() { renderer.material.color = initialColor; 
                       textObject.text = "";}

Look for materialS (with the S) array in Unity - Scripting API: Renderer

renderer.material is really just a shortcut for renderer.materials[0]. To change them all, just use a loop.

But, often just changing color won’t look right. You may want to make another set of “red” materials, also save the originals, and swap materials in/out (instead of the color change.)