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?
Also, I cannot get all materials with GetComponent<Renderer> ().materials; it displays an error. I am only able to get single material of the gameObject with GetComponent<Renderer> ().material;. What is the problem here?
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> ().materials;
}
}