Let’s say I have a list of vertices. Those are 2D vertices (z component is always zero).
I’d like to know if there’s a way to build at runtime a mesh from those vertices. That mesh should have colliders, texturing and whatever.
And, if the list of vertices changes at runtime (for example I update their y component), is there a way to update that mesh (with colliders and so on) also at runtime?
followed by a google of “unity mesh procedural”…
Yes you can, however just the vertices isn’t enough. You also need to know how to build triangles out of them, and which way to wind them.
Anything with a mesh should have a MeshFilter component attached to it.
From the MeshFilter, you can access it’s mesh, which has type Mesh. The docs for Mesh show how to assign vertices to the mesh, then how to define the triangles that make the mesh.
Making the triangles is the hard part. Pretty much you need to figure out which three vertices make up each triangle, and the order of the vertices correctly. Triangles are one sided, so if you order the vertices the wrong way, you’ll “see” the back of the triangle which is invisible. So I guess you won’t see it. =p
EDIT: If you are slightly moving existing vertices, you might not need to worry about the triangles.