Here example of the problem
ProBuilderMesh BuildQuad(Vector3 pos) {
ProBuilderMesh quad = ProBuilderMesh.Create(
new Vector3[] {
new Vector3(0, 0, 0),
new Vector3(0.5f, 0, 0),
new Vector3(0, 0, 0.5f),
new Vector3(0.5f, 0, 0.5f),
new Vector3(1f, 0, 0),
new Vector3(1f, 0, 0.5f),
new Vector3(0, 0, 1f),
new Vector3(0.5f, 0, 1f),
new Vector3(1f, 0, 1f),
},
new Face[] {
new Face(new[] {0, 2, 1, 2, 3, 1}),
new Face(new[] {1, 3, 4, 3, 5, 4}),
new Face(new[] {2, 6, 3, 6, 7, 3}),
new Face(new[] {3, 7, 5, 7, 8, 5}),
}
);
quad.transform.position = pos;
return quad;
}
void Start() {
ProBuilderMesh plane1 = ShapeGenerator.GeneratePlane(PivotLocation.Center, 1, 1, 1, 1, Axis.Up); // this gets quad/plane with 16 vertices
ProBuilderMesh plane2 = ShapeGenerator.GeneratePlane(PivotLocation.Center, 1, 1, 1, 1, Axis.Up); // this gets quad/plane with 16 vertices
ProBuilderMesh quad1 = BuildQuad(new Vector3(2, 0, 2)); // this gets quad/plane with 9 vertices
ProBuilderMesh quad2 = BuildQuad(new Vector3(3, 0, 2)); // this gets quad/plane with 9 vertices
List<ProBuilderMesh> planes = new List<ProBuilderMesh>() {plane1, plane2};
ProBuilderMesh planesMesh = CombineMeshes.Combine(planes, planes.First()).First();
Debug.Log(planesMesh.GetVertices().Length);
MeshUtility.CollapseSharedVertices(planesMesh.GetComponent<MeshFilter>().sharedMesh); // doesnt work
planesMesh.ToMesh();
planesMesh.Refresh();
Debug.Log(planesMesh.GetVertices().Length);
List<ProBuilderMesh> quads = new List<ProBuilderMesh>() {quad1, quad2};
ProBuilderMesh quadsMesh = CombineMeshes.Combine(quads, quads.First()).First();
Debug.Log(quadsMesh.GetVertices().Length);
MeshUtility.CollapseSharedVertices(quadsMesh.GetComponent<MeshFilter>().sharedMesh);// doesnt work 18 vertices in my understanding there should by 15 as 3 vertices are shared after merging 2 quads at those positions
quadsMesh.ToMesh();
quadsMesh.Refresh();
Debug.Log(quadsMesh.GetVertices().Length);
}
How I could possibly reduce the sharedvertices after combining the meshes?? For love is there noone who could help me on that? Is Probuilder cappable of doing this via API?? It can do it in editor but how to do it in code??
@kaarrrllll would you be able to suggest/help with this? Seems you’re only the one who knows something