- Home /
Renderer isn't changing Materials
Hello,
I've got a simple script that changes the Mat of an object. The object has two Material elements but this
children.GetComponent<Renderer>().materials[0] = mat1;
children.GetComponent<Renderer>().materials[1] = mat2;
Should this not change the mats? It doesn't seem to do anything nor does it throw an error.
However this does work
children.GetComponent<Renderer>().material = mat;
but it only changes the first element. I taken a look at a lot of posts around the internet but haven't been able to find a fix.
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612200902im_/https://answers.unity.com/themes/thub/images/avi.jpg)