- Home /
 
 
               Question by 
               SpeedTutor · Oct 18, 2013 at 05:17 PM · 
                javascriptarraymaterial  
              
 
              Changing materials with array
Hello, I really don't understand how to use array's in this isntance but I'm trying to change one material to another. I have two materials in the array, a normal colour (Diffuse) and a refractive material. I want to switch between those two. I'm not sure how to specify the specific material, as I want to change from the diffuse to the refractive.
 #pragma strict
 
 var materials : Material[];
      
 function Update() 
 {
     if(Input.GetKeyDown("f")) 
     {
     if(renderer.material == materials[0])
     renderer.material = materials[1];
     }
 }
 
               Thanks.
               Comment
              
 
               
              Your answer