- Home /
Submesh Vertices
I have a lot of experience when it comes to meshes, ive worked with procedural meshes in unity for a while, but i wanted to ask, how do submeshes work ? I am looking through the wiki and ive read that submeshes are pretty much the same as meshes, yet i cant seem to find how to set vertices of a submesh? is there a way to kind of make a seperate mesh , apply the vertices, triangles, uvs and make it a submesh? I cant find a submesh alternative for setting vertices, i kind of get how it works but there isnt as much documentation on submeshes as there is with meshes.
Basically, how do i use submeshes like i do with meshes?
Answer by DaveA · Sep 06, 2013 at 06:03 PM
Submeshes use the same exact vertex list as the mesh, they are just additional triangle lists.
See http://docs.unity3d.com/Documentation/ScriptReference/Mesh.SetTriangles.html and http://docs.unity3d.com/Documentation/ScriptReference/Mesh.CombineMeshes.html
yeah but, i cant manually set the vertices? also vertices are vector3 positions. do i feed it the x y and z seperately or something?
@Bunnybomb7670: you don't do anything differently, except you have separate triangle lists. Ins$$anonymous$$d of $$anonymous$$esh.triangles (which is one triangle list), you have more than one, as indicated by $$anonymous$$esh.SetTriangles. That's it.
yes, i get that bit, but how do i feed it vertex positions, do i feed it the x y z as single values or what? with a normal mesh, i set the mesh.vertices, mesh.triangles and mesh.uvs and so on, with a submesh i cant do vertices. what do i do ins$$anonymous$$d.
You don't do anything differently, except the triangle lists. It is exactly the same as working on any other mesh. For example, a mesh with one submesh (so basically a standard mesh), ins$$anonymous$$d of my$$anonymous$$esh.triangles = tris;
, you do my$$anonymous$$esh.SetTriangles(tris, 0);
. For more submeshes you have additional triangle lists and use 1, 2, 3, etc.
You don't 'add vertices to a submesh'. You add vertices to THE $$anonymous$$ESH and set the triangle list(s) which ARE submeshes to reference (index) those new vertices. So if you want to alter it, get the vertices into an array, add to that array (or copy to a new bigger array), and set the vertices again. ON THE $$anonymous$$ESH. There is no 'setting vertices on submesh'
Your answer
![](https://koobas.hobune.stream/wayback/20220613113714im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Combine (skinned) submeshes causes increased vertcount(for each submesh the whole vertcount) 0 Answers
Sort mesh vertices before automatic sub-mesh creation 0 Answers
Alternative Ways of Finding Vertices 2 Answers
Import mesh with submeshes from OBJ? 2 Answers
Changing Mesh Vertex Colors in editor 0 Answers