- Home /
Question by
Vire · Jan 31, 2014 at 04:54 AM ·
c#materialskinnedmeshrenderer
Skinned Mesh Renderer - Adding/Removing Materials via C#
I am trying to add a material to my skinned mesh renderer via code. Then later I need to be able to remove it via code and reduce the array size back to 1 from 2. It has to be added, not changed.
What I believe should work isn't working.
public Material leatherArmorMaterial;
^ mtl
GetComponent().materials[1] = mtl;
This doesn't work. It doesn't error and it doesn't do anything.
If I do
bodyGeo.gameObject.GetComponent().material = mtl;
It will change the first material to the prefab loaded into leatherArmorMaterial
.
I can't find any other option for adding/removing materials. Can anyone assist me?
Thanks.
Comment