Question by
prithul · May 05, 2016 at 03:38 PM ·
meshprocedural meshtrianglesmeshfilter
Can't get submesh to work
I have been trying to make a mesh with multiple submeshes. But it just isn't working. I am pretty sure I did what the documentation said me to do:
void Start () {
gameObject.AddComponent<MeshRenderer>();
MeshFilter mf = gameObject.AddComponent<MeshFilter>();
mf.mesh.Clear();
mf.mesh.vertices = new Vector3[]
{
new Vector3(0,0,1f),
new Vector3(1,0,1f),
new Vector3(0,1,1f),
new Vector3(1,1,1f),
};
mf.mesh.subMeshCount = 2;
mf.mesh.SetTriangles(new int[] { 0,1,2
}, 0);
mf.mesh.SetTriangles(new int[] { 2,1,3
}, 1);
}
It only shows one of the triangles. Only one of the submeshs are visible at a time. Though I set submesh count to 2. Am I doing something wrong?
Comment
Answer by prithul · May 06, 2016 at 08:35 AM
Doesn't any one have a single clue about what I am doing wrong? :/