- Home /
Question by
Henrique Vilela · May 19, 2011 at 07:19 PM ·
materialcolorlightmapmeshrenderer
Change the material of a lightmapped object
I'm changing the color property of a material of a lightmapped object on the fly using this code:
MeshRenderer mesh = gameObject.GetComponent<MeshRenderer>();
mesh.material.color = new Color(255, 255, 255);
The problem is that when I do it the color does change, as it's supposed to do, but the object lose his lightmap. Anybody knows why it happen and if there's any workaround to solve it?
PS: If I change the color property by the inspector panel instead of code, it works.
Comment
Best Answer
Answer by Henrique Vilela · May 20, 2011 at 12:52 PM
The problem was the color values, it was supposed to be on the 0 to 1 range.
new Color(1, 1, 1);