I'm currently using this code so far :
//Change renderer's material each changeInterval
// seconds from the material array defined in the inspector.
var materials : Material[];
var changeInterval = 0.33;
function Update () {
if (materials.Length == 0) // do nothing if no materials
return;
// material index
var index : int = Time.time / changeInterval;
// take a modulo with materials count so that animation repeats
index = index % materials.Length;
// assign it to the renderer
renderer.sharedMaterial = materials[index];
}
( Found from Unity Script Reference Help )
and it's working for switching the materials on my plane by a timer. I would like to know if there is a way to make this better by making the materials switch with a button such as a Mouse click or just a button press. Even better would be to figure out a way to click on a made button in the game for the "next material" button.
The furthest I figure is somehow making a counter.
Please help!
OK, to make this simpler, since I don't want to use a Gui....if I use a Input.GetKeyDown button instead...how would I make that?? Something like ..? function Update() { if(Input.GetKeyDown("a").Button, "Next Material:)?
– anon29492787ok, i fixed my answer, hope it helps!
– anon94362555