- Home /
How to add vertex points to a mesh
Hello,
if I have for example the default Unity cube, how can I add vertices to that mesh? Let's say a vertex in the middle of each side of the cube, and add them so they are really a part of the cube mesh.
Thanks
Alright so that's the only thing I need to do? I can just add vertices to the array? Neat.
The problem with meshes you didn't generate yourself via code is that you have no easy way of knowing the index of each vertex (in the vertex array), so it becomes a matter of trial & error when creating the triangles array. It's probably better to generate your own cube mesh.
Answer by Cherno · Jun 16, 2017 at 10:44 PM
I suggest reading the Scripting API for the Mesh class.
Basically, a mesh consists of at least two things: vertices and triangles. So in order to add a new vertex, you would add it to the vertex array and then reassign all vertices to triangles.
That's great! And also, my meshes are generated by myself through code so that'll help!