I want to move some vertices on a very simple mesh to modify its shape.
I put the mesh into the world by instantiating a Prefab as a GameObject, so all I know is how to reference the GameObject.
I don’t know the first thing about referencing vertices, meshes, meshfilters or anything and cannot seem to find the answers on google.
Any help greatly appreciated!
Start with GameObject.GetComponent
to reference the MeshFilter
, then use the MeshFilter.mesh
(in runtime) or MeshFilter.sharedMesh
(in edit time) to reference the Mesh
itself, then use the Mesh.vertices
to get the vertices of the mesh.
It’s important to note that the Mesh.triangles
can also be accessed, and it’s always a multiply of the Mesh.vertexCount
by 3, where each triangle is defined by 3 vertices starting from Mesh.vertices[0]
.