Looping on materials..

I am trying to loop on every materials to change the color but I only arrive to the “Starting” message and, without an error, I do not get the “array length” message. Please help. The code:

private var r : Renderer[];

function Start () {
Debug.Log("Starting");
r = gameObject.GetComponentsInChildren(Renderer,true);
Debug.Log("Array lenght:" + r.Length);
  for (var m : Renderer in r) {
        m.material.color.a=0;
    }
    
}

2 Answers

2

Try

r = gameObject.GetComponentsInChildren.< Renderer >(true);

Thanks to whydidoit for the missing dot! And to Fabio, could you mark this question as answered please, sir?

Ok, it works but you missed a dot:

r = gameObject.GetComponentsInChildren.< Renderer >(true);

thanks a lot