GetTriangles
Fetches the triangle list for the specified sub-mesh on this object.
Read time 5 minutesLast updated 4 days ago
Definition
- Type: Method
- Namespace: UnityEngine
- Assembly: UnityEngine.CoreModule
GetTriangles(int)
Fetches the triangle list for the specified sub-mesh on this object.
public int[] GetTriangles(int submesh)
Parameters
The sub-mesh index. See Mesh.subMeshCount.
Returns
Type | Description |
|---|---|
| int[] |
Remarks
Each integer in the returned triangle list is a vertex index, which is used as an offset into the Mesh's vertex arrays. See Mesh.vertices and Mesh.GetVertices. The triangle list contains a multiple of three indices, one for each corner in each triangle.
A sub-mesh represents a list of triangles that are rendered using a single Material. When the Mesh is used with a Renderer that has multiple materials, you should ensure that there is one sub-mesh per Material.
Call the method overload with a parameter if you control the life cycle of the index buffer and wish to avoid allocation of a new array with every access.
List<int>Additional Resources: Mesh.subMeshCount.
GetTriangles(int, bool)
Fetches the triangle list for the specified sub-mesh on this object.
public int[] GetTriangles(int submesh, bool applyBaseVertex)
Parameters
The sub-mesh index. See Mesh.subMeshCount.
True (default value) will apply base vertex offset to returned indices.
Returns
Type | Description |
|---|---|
| int[] |
Remarks
Each integer in the returned triangle list is a vertex index, which is used as an offset into the Mesh's vertex arrays. See Mesh.vertices and Mesh.GetVertices. The triangle list contains a multiple of three indices, one for each corner in each triangle.
A sub-mesh represents a list of triangles that are rendered using a single Material. When the Mesh is used with a Renderer that has multiple materials, you should ensure that there is one sub-mesh per Material.
Call the method overload with a parameter if you control the life cycle of the index buffer and wish to avoid allocation of a new array with every access.
List<int>Additional Resources: Mesh.subMeshCount.
GetTriangles(List<int>, int)
Fetches the triangle list for the specified sub-mesh on this object.
public void GetTriangles(List<int> triangles, int submesh)
Parameters
A list of vertex indices to populate. Any existing items in the list are replaced.
The sub-mesh index. See Mesh.subMeshCount.
Remarks
Each integer in the returned triangle list is a vertex index, which is used as an offset into the Mesh's vertex arrays. See Mesh.vertices and Mesh.GetVertices. The triangle list contains a multiple of three indices, one for each corner in each triangle.
A sub-mesh represents a list of triangles that are rendered using a single Material. When the Mesh is used with a Renderer that has multiple materials, you should ensure that there is one sub-mesh per Material.
Call the method overload with a parameter if you control the life cycle of the index buffer and wish to avoid allocation of a new array with every access.
List<int>Additional Resources: Mesh.subMeshCount.
GetTriangles(List<int>, int, bool)
Fetches the triangle list for the specified sub-mesh on this object.
public void GetTriangles(List<int> triangles, int submesh, bool applyBaseVertex)
Parameters
A list of vertex indices to populate. Any existing items in the list are replaced.
The sub-mesh index. See Mesh.subMeshCount.
True (default value) will apply base vertex offset to returned indices.
Remarks
Each integer in the returned triangle list is a vertex index, which is used as an offset into the Mesh's vertex arrays. See Mesh.vertices and Mesh.GetVertices. The triangle list contains a multiple of three indices, one for each corner in each triangle.
A sub-mesh represents a list of triangles that are rendered using a single Material. When the Mesh is used with a Renderer that has multiple materials, you should ensure that there is one sub-mesh per Material.
Call the method overload with a parameter if you control the life cycle of the index buffer and wish to avoid allocation of a new array with every access.
List<int>Additional Resources: Mesh.subMeshCount.
GetTriangles(List<ushort>, int, bool)
Fetches the triangle list for the specified sub-mesh on this object.
public void GetTriangles(List<ushort> triangles, int submesh, bool applyBaseVertex = true)
Parameters
A list of vertex indices to populate. Any existing items in the list are replaced.
The sub-mesh index. See Mesh.subMeshCount.
True (default value) will apply base vertex offset to returned indices.
Remarks
Each integer in the returned triangle list is a vertex index, which is used as an offset into the Mesh's vertex arrays. See Mesh.vertices and Mesh.GetVertices. The triangle list contains a multiple of three indices, one for each corner in each triangle.
A sub-mesh represents a list of triangles that are rendered using a single Material. When the Mesh is used with a Renderer that has multiple materials, you should ensure that there is one sub-mesh per Material.
Call the method overload with a parameter if you control the life cycle of the index buffer and wish to avoid allocation of a new array with every access.
List<int>Additional Resources: Mesh.subMeshCount.