I have two identical instances of a prefab in a scene. One is placed there at edit time. One is instantiated at run time.
Then, I get the MeshRenderer component of each and try to update the material to use a new material (meshRenderer.material = newMat)
The prefab that was placed in scene updates its material as expected. The instantiated prefab does not. I am at a total loss as to why.
I tried debugging and found that the material property of the MeshRenderer does seem to get updated in both cases (at least according to the Visual Studio debugger Locals panel). However, if you look at the instantiated object in the Unity Inspector, it still shows the original material.
One more note, I can manually drag a material at runtime in the Unity Editor onto either MeshRenderer component and that seems to work fine as well.
Any idea what’s going on here?