Version: 2017.1

Mesh.GetTriangles

Switch to Manual
public void GetTriangles (List<int> triangles, int submesh);
public int[] GetTriangles (int submesh);

Parameters

triangles A list of vertex indices to populate.
submesh The sub mesh on this instance. See subMeshCount.

Description

Gets the triangle list for the specified sub mesh on this instance.

Each element value in the returned triangle list refers to a vertex index, which can be used to index into the results of other accessors like vertices and GetVertices. It will return indices in multiples of three.

A sub mesh is simply a separate triangle list. When the mesh is rendered using multiple materials, you should ensure that there is one sub mesh per Material.

Call the method overload with a List<int> parameter if you control the life cycle of the index buffer and wish to avoid allocation of a new array with every access.

See Also: subMeshCount.