Array of materials from array of objects
I have an array of objects. I need to store the original materials in order to reapply them after it has been temporarily changed.
I currently have:
public int redModeNum; //this is for choosing number in list, not sure needed
public GameObject[] redList = new GameObject[redModeNum]; //this stores objects dragged in from unity
public Material[] redListMats = new Material[redModeNum]; //this is to store 1 material from each object
When I try the following code I get a "endexOutOfRangeException":
redListMats[0] = redList[0].GetComponent().material;
However, the following is changing original to red but can't change back due to not storing.
redList[0].GetComponent.material = redMaterial; //redmaterial is a public I added as the temporary color
Problem really is even after I figure out how to store 1 material from these objects some of my objects have 2 or more materials that I'll need to store and not sure if a Material[][] will work since this isn't.
Thanks everyone for help.