I’m trying to color a mesh using vertex colors and I can’t get it to work. I’m using the Mobile/VertexLit shader. Here’s my code:
void Start () {
Mesh mesh = GetComponent<MeshFilter>().mesh;
Color[] colors = new Color[mesh.vertexCount];
for (int i = 0; i < mesh.vertexCount; i++)
{
colors *= Color.black;*
-
}* -
mesh.colors = colors;* -
}*
What am I doing wrong?
That's hard to answer. What is going wrong? Are you crashing? Are the visuals not what you expected? Do you have a shader that is using the vertex color channel?
– StatementTry the Mobile/Vertex Colored shader.
– robertbuIt just doesn't color the object. I don't seem to have the "Mobile/Vertex Colored" shader. Maybe I'm doing this wrong. I created a material and set the shader to Mobile/VertexLit. Then I added that material to my model. Am I supposed to set up the shader some other way?
– toborific