I’m having a problem in Unity 5.5.f1 where if I change a material during run time it does NOT add the material that I want. I have a reference to a prefab material, and when I change the material to that, then it just adds the ‘Default Material’ instead. The material works fine in the editor, and the shader is not broken either.
Here is how I am changing the material in my code:
public Material outlineMat; // The material that I want to change to
if(/* im looking at this */)
{
computerMeshRend.materials[1] = outlineMat;
}
// Otherwise put it to null
else
{
computerMeshRend.materials[1] = null;
}
I can’t pick out why this is happening… Possibly has something to do with the material being a prefab?