- Home /
Error while setting triangles list of submesh from C#
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?
Answer by keless · Feb 23, 2013 at 01:59 AM
Shot in the dark: it might not be casting correctly in the case of passing into a function param, vs assigning a setter.
Try the following--
int[] test = triangles.ToArray();
mesh.SetTriangles(test,0);
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Flip over an object (smooth transition) 3 Answers
uv sub meshes in cube c# 0 Answers