- Home /
Access Multiple Renderer Materials?
Hello,
I have a model that I made in Maya, and within the renderer I can see all my materials applied to this particular model listed in an array:
I want to be able to change them independently via JS, how would I access them? I thought I could do it like this:
gameObject.renderer.material[1] = myMaterial;
But I get a slicing error in the console, any ideas how I can achieve this? Thanks
Answer by vexe · Oct 10, 2013 at 02:58 PM
Forgot the 's' ^^ renderer.materials
gameObject.renderer.materials[1] = myMaterial;
Okay, I can't seem to get my material to apply. This works:
nurbs.gameObject.renderer.materials[1].color = Color.yellow;
This doesn't:
nurbs.gameObject.renderer.materials[1]= my$$anonymous$$aterial;
$$anonymous$$ake sure you're using the proper shader. For me, I just tried to change my skybox that I have wrapped around my cube. I first tried to change it to another material, which had a RenderFX/Skybox
shader, it didn't work. But when I used a material with a Diffuse
shader, it worked.