Teach me a little bit about submeshes, if you could.

I’m working on creating meshes from within Unity for the first time. I just came across this concept of submeshes, but can’t figure out exactly how they are meant to be used…

It seems that you need one submesh per material, but how would you go about assigning each material to only a particular submesh?

Also, I’d like some advice on whether this idea is in good form:

I’m making several pairs of triangles (rectangles), of which I intend to modify the UV coordinates, “sliding” the polys over a texture in order to affect the appearance of a GUI. Is it good form to use a submesh for each rectangle, or is that pointless? (As I said, I’m completely inexperienced and am formulating a method of attack.)

In Blender, for example, select some UV points and assign a texture to them, then invert the selection and assign a different texture to that. When imported into Unity, it has two materials.

Yeah, it’s pretty pointless, if I’m understanding you correctly. An object with two submeshes with different materials is, as far as performance goes, basically the same thing as two objects. If you have submeshes with the same material, then there’s no reason I can think of to have submeshes in the first place.

–Eric

I’m talking about assigning the materials in Unity.

I didn’t know if it was a technique that could aid in grouping triangles together logically, as opposed to assigning a subset of the vertices of a mesh to well-named arrays.

Someone asked me for some help with Blender → Unity today. They wanted to know why their submeshes were not being colored properly. It seems that Blender messes up what materials should be assigned to which submesh, if your mesh uses more than 2 materials (actually, I only tested with 3 materials, so maybe it gets better from 4 onwards :wink: ).

Does anyone have a Blender workaround? (You can fix the order of the material slots, and that seems to be preserved when you reimport the mesh, if it is in the scene, but if you drag in a new mesh, that material reassignment is not preserved.)