Setting materials of child objects

I am trying to set the material of child game objects with little success.

The hierarchy is this:

ArticlePaper (this is the parent)

ArticlePaper (this is a child)

ArticlePaper (this is a child)

So what I need to do is update the material for the children NOT the parent but whatever I try I either get just one changed or as this below none?:

foreach(Transform t in current.transform) {

	List<Material> currentMats = new List<Material>();

	currentMats.Add(plainMaterial);

	t.Find(current.gameObject.name).GetComponent<Renderer> ().materials = currentMats.ToArray();			

}

Try something like

int numOfChildren = transform.childCount;
for(int i = 0; i < numOfChildren; i++)
{
    GameObject child = transform.GetChild(i).gameObject;
    child.GetComponent<Renderer>().materials = currentMats.ToArray();
}

hi, i’m new to this but got a similar problem. I set all my GameObject children with the same name and i was trying to get every child by that name, so unity only returns the first child.

Try to set different names or just get your children by index