It looks like faces are moved, but not the object. Does it have something to do with the fact that the Rebuild() method doesn’t exist, despite what’s written in the example?
My next question is related to the “Subdivide objet” function in the Probuiler editor window: How do you call it from code?
Last question: Through code, how can one slightly move (I’m talking about a few inches in a mesh with meters long edges) the vertices of a mesh (keeping the mesh “gathered” of course, meaning vertices with the same position remain at an identical position).
That looks like the correct results, you just need to let the editor know to rebuild the wireframe. Use ProBuilderEditor.Refresh(); after modifying a mesh to update the scene gizmos.
Okay, so a couple more questions:
Replicating the way the “create a mesh” API example works, the script I wrote creates a mesh that is basically a serie of vertical faces:
But as you can see, the texture on the face on the right is stretched. I also noticed that if I use the “triangulate” function, everything is back in order:
What is the problem? And how can I solve it (using the triangulate function or not) through script?
Here is the code:
List<Vector3> vertices = new List<Vector3> ();
List<Face> faces = new List<Face>();
// tempMarkers is an array of vector3 coordinates, representing a "base line" from which the faces will be created
for (int i = 0; i < tempMarkers.Count; i++)
{
vertices.Add(tempMarkers[i]);
vertices.Add(new Vector3(tempMarkers[i].x, tempMarkers[i].y + heightParameter, tempMarkers[i].z));
}
for (int i = 0; i < points.Count-3; i = i+2)
{
faces.Add(new Face(new int[] { i, i+2, i+1, i+2, i+3, i+1 }));
}
pb = ProBuilderMesh.Create(vertices, faces);
pb.Refresh();
EditorMeshUtility.Optimize(pb, true);
It looks to me like the faces you’re creating are not square quads. If you open the ProBuilder Editor window you can visualize what the those quads look like.