Question by
infinitypbr · Apr 03, 2016 at 02:57 AM ·
materialmaterial color
Changing Multiple Materials on One Object via Code
Per the unity docs and some forum answers, I would think this would work, but it doesn't. It doesn't actually do anything -- no errors etc.
There's two materials on an array of SkinnedMeshRenderers, and one for the hairBuzzed (also a skinnedMeshRenderer).
There are no errors, but the materials aren't switched. Any ideas what I could be doing wrong?
function SetHair(newValue : int){
for (var i : int; i < hair.Length; i++){
hair[i].materials[0] = hairMaterialsA[newValue];
hair[i].materials[1] = hairMaterialsB[newValue];
print ("Mat: " + hair[i].materials[0] + " | " + hair[i].materials[1]);
}
hairBuzzed.materials[0] = hairMaterialsB[newValue];
}
Comment
Your answer
