How do I get all the materials from a gameObject (Some have 5-10 materials) and set the same texture to each of these materials?
public GameObject go;
public Texture texture;
void Start()
{
go.GetComponent<Renderer>().material.SetTexture("_BaseMap", texture);
}
I got the way to do this. By getting all materials into an array.
Material[] myMaterials = gameObject.GetComponent<Renderer> ().materials;
for (int i = 0; i < myMaterials.Length; i++) {
myMaterials[i].SetTexture ("_BaseColorMap", texture);
}
public GameObject go,go1,go2; Try it this way