I am getting all materials from the parent and its children and storing it in an array. I want to however ignore few gameObjects from the list to be added. Can I add a string as the gameObject's name to be ignored so that except these gameObject, everything gets added?
Another thing is, how do I get all and each material from each gameObject? Few gameObjects have 5 and others have only 1. With the below code, I could only receive only one material from each gameObject.
public Renderer[] allChildRenderers;
public Material[] allMaterials;
public string[] GameObjects_ToIgnore;
void Start () {
allChildRenderers = GetComponentsInChildren<Renderer> ();
allMaterials = new Material[allChildRenderers.Length];
for (int i = 0; i < allChildRenderers.Length; i++) {
allMaterials[i] = allChildRenderers[i].GetComponent<Renderer> ().material;
}
}
}
