- Home /
Display a procedural mesh in the editor
I have a mesh that I generate procedurally in the editor, while the game is not running. For some reason, I can not get it to actually display.
I can see that the code generating the mesh (which works correctly when playing the game) is being executed correctly. The mesh is also being assigned correctly to the MeshFilter, the MeshRenderer also has the materials assigned properly.
Upon further investigation, I found that the vertices were being assigned into the mesh, but the triangles and submeshes were not, though in the code below, you can see they are being assigned together. This same code sets creates the mesh in the editor and in the game.
the actual assignment to the triangles in this case uses the SetTriangles function, because the mesh is composed of three submeshes.
mesh.MarkDynamic();
mesh.Clear();
mesh.subMeshCount = numLayers[TriangleList.Top] + numLayers[TriangleList.Bottom] + numLayers[TriangleList.Sides];
mesh.vertices = newVertices;
mesh.uv = newUV;
var totalLayers:int = 0;
for(i = 0 ; i
I suggest showing the whole thing in this case.... the devil is often in the details.
Your answer

Follow this Question
Related Questions
Mesh Collider Edge Position. 0 Answers
Sphere made of cubes algorithm 4 Answers
Splitting vertices in a mesh specifically a plane 0 Answers
Procedurally created mesh appearing offset from it's vert locations. 1 Answer
C# Proceducal Mesh terrain 2 Answers