I’m trying to refactor my code that was using a single mesh, splitting it into submeshes.
I’m using SetTriangles method of Mesh object, like suggested in my previous question.
In the previous and working version I had the following lines:
List<int> triangles = new List<int>();
...
//fill up vertex buffer, triangles list and uv..
mesh.triangles = triangles.ToArray();
Now I’m trying the following:
List<int> triangles = new List<int>();
...
//fill up vertex buffer, triangles list and uv..
mesh.subMeshCount = 1;
mesh.SetTriangles(triangles.ToArray(),0); //compiler error here
But I have a compiler error on the last line:
error CS0029: Cannot implicitly convert type 'void' to 'int[]'
Now the return type of ToArray is actually int. So, I don’t know how to fix this.
Could someone tell me what’s the error here?