- Home /
Question by
Haden2 · Jul 03, 2015 at 01:55 PM ·
shadergameobjectarraymaterial
Change all materials then return the old materials?
I have figured out how to change all of the materials in my game at the same time using
if(Input.GetKeyDown("3"))
{
for(int i = 0 ; i < environ.Length ; i++)
{
rend[i] = environ[i].GetComponent<Renderer>();
rend[i].material.shader = echo;
rend[i].material = EchoMaterial;
}
With echo and EchoMaterial being shaders and materials. But I cannot figure out a way to store all of the game objects current material at the start of the game, so that at another push of a button the materials return to what they were before. Is there a way to assign all of the materials to an array or something so that they can all be returned? Or do I have to go through every individual game object and set a variable to be its old material and then manually assign each one?
Comment