I’ve been having a good old dig around for an answer to this and feel like I’ve been close a few times, but without a good solution. Would really appreciate any help you can muster on this.
I’m generating meshes from a floorplan as an extruded form of a polygon, sometimes with holes in. All this is fine and had that working (rudimentary, but working). But I’ve come across a new use case recently where a floorplan may be split into multiple parts. Think two disconnected squares.
So my script is adjusted for this and is creating multiple meshes as CombineInstances, then the sharedMesh is Combined from these multiple meshes.
Problem is, after running mesh.CombineMeshes, I’m just getting (0,0,0) vertexes. The correct number of vertices. Triangles also seem to be set correctly, but zero for every vertex. VertexCount is only 451, so I’m in no danger of exceeding that.
Here’s the code that combines the meshes.
public Mesh Extrude ()
{
CombineInstance[] combiners = new CombineInstance[geometry.outlines.Length];
for ( int i = 0; i < combiners.Length; i++ )
{
int vertCount = geometry.VertexCount ( i );
Shape shape = geometry.outlines[i];
Shape[] holes = geometry.holes[i];
Mesh partMesh = new Mesh ();
List<Vector3> vertices = new List<Vector3> ( vertCount * 3 );
List<int> triangles = new List<int> ();
CreateEdgeVertices ( vertices, shape, holes);
CreateEdgeTriangles ( triangles, shape, holes, vertCount);
CreateFaceVertsAndTris (vertices, triangles, shape, holes, vertCount);
partMesh.vertices = vertices.ToArray ();
partMesh.triangles = triangles.ToArray ();
partMesh.RecalculateBounds ();
partMesh.Optimize ();
partMesh.RecalculateNormals ();
combiners[i].mesh = partMesh;
}
mesh.CombineMeshes ( combiners );
return mesh;
}
Definitely missing something here, just not sure what it is.
Thanks in advance