- Home /
 
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;
     }
     
 }
 
              
               Comment
              
 
               
              Answer by iwaldrop · Mar 25, 2013 at 11:10 PM
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?
Answer by fabio1955 · Mar 26, 2013 at 07:46 AM
Ok, it works but you missed a dot:
 r = gameObject.GetComponentsInChildren.< Renderer >(true);
 
               thanks a lot
Your answer