- Home /
Generated mesh has material under submeshes' materials
Sorry I have a if the title is confusing, I don't know how to put it better.
I generate a mesh of cubes minecraft-style, with each face that has a distinct material being one sub-mesh (to minimize the number of materials).
In the end, ALL triangles created are assigned to submeshes, and the renderer is given an array of materials to correspond to the number of submeshes... as it should be.
The problem is that apparently the "main mesh" also uses the first material in the array and in fact it shows up underneath the submesh material if using a transparent texture or moving a light source very close to the surface. Is there any way to stop the base mesh having it'w own material?
Answer by Cherno · Apr 14, 2014 at 03:11 AM
Heh... I actually thought of a solution while typing the question, and it works.
I just add an empty int list to the mesh as a submesh, and also add an invisible material to the material array. Now, the first material is invisible, and the first (empty) submesh corresponds to that material. Since the base mesh always uses the first material, it won't show up any longer.
Your answer
![](https://koobas.hobune.stream/wayback/20220613142646im_/https://answers.unity.com/themes/thub/images/avi.jpg)