for (int i = 0; i < waypoints.Length; i++)
{
foreach (Transform g in waypoints[i].GetComponentsInChildren<Transform>())
{
if (g.GetComponent<MeshRenderer>() != null)
{
meshRenderers.Add(g.GetComponent<MeshRenderer>());
}
if(g.GetComponent<Material>() != null)
{
materials.Add(g.GetComponent<Material>());
}
}
}
I can get the MeshRenderer from each object children there are like 1000 MeshRenderers.
and in the editor, I can see that each child with MeshRenderer also have a material component. for example:
I want to get also the Material from each child if there is any material but I'm getting 0 items in the materials List.
later on I want to manipulate the materials but first I can't even get them to a List.
