Hello,
I tried to generate mesh(just a triangle here) on the run from a script, and the colors don't work. The triangle appears always pink (looks like Color(255,0,255)). No matter what I set to the vertex colors to. Any idea why this could happen? Do I need to have a material/shader for this to work?
Here's the code
void Start() {
gameObject.AddComponent("MeshFilter");
gameObject.AddComponent("MeshRenderer");
Mesh mesh = GetComponent<MeshFilter>().mesh;
mesh.Clear();
mesh.vertices = new Vector3[] { new Vector3(-0.5f, 0, 0),
new Vector3(0, 1, 0),
new Vector3(0.5f, 0, 0) };
mesh.normals = new Vector3[] { new Vector3(0, 0,-1),
new Vector3(0, 0,-1),
new Vector3(0, 0,-1) };
mesh.colors = new Color[] { new Color(0,0,0),
new Color(0,0,0),
new Color(0,0,0) };
mesh.triangles = new int[] { 0, 1, 2 };
}