# GetTriangles

> Fetches the triangle list for the specified sub-mesh on this object.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.6/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

## GetTriangles(int)

Fetches the triangle list for the specified sub-mesh on this object.

```csharp
public int[] GetTriangles(int submesh)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The sub-mesh index. See [Mesh.subMeshCount](/engine/6000.6/script-reference/unityengine/mesh/submeshcount.md).

### Returns

| Type                                                           | Description |
| -------------------------------------------------------------- | ----------- |
| [int\[\]](https://learn.microsoft.com/dotnet/api/system.int32) |             |

### 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](/engine/6000.6/script-reference/unityengine/mesh/vertices.md) and [Mesh.GetVertices](/engine/6000.6/script-reference/unityengine/mesh/getvertices.md). 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](/engine/6000.6/script-reference/unityengine/material.md). When the Mesh is used with a [Renderer](/engine/6000.6/script-reference/unityengine/renderer.md) that has 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.

Additional Resources: [Mesh.subMeshCount](/engine/6000.6/script-reference/unityengine/mesh/submeshcount.md).

## GetTriangles(int, bool)

Fetches the triangle list for the specified sub-mesh on this object.

```csharp
public int[] GetTriangles(int submesh, bool applyBaseVertex)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The sub-mesh index. See [Mesh.subMeshCount](/engine/6000.6/script-reference/unityengine/mesh/submeshcount.md).**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): True (default value) will apply base vertex offset to returned indices.

### Returns

| Type                                                           | Description |
| -------------------------------------------------------------- | ----------- |
| [int\[\]](https://learn.microsoft.com/dotnet/api/system.int32) |             |

### 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](/engine/6000.6/script-reference/unityengine/mesh/vertices.md) and [Mesh.GetVertices](/engine/6000.6/script-reference/unityengine/mesh/getvertices.md). 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](/engine/6000.6/script-reference/unityengine/material.md). When the Mesh is used with a [Renderer](/engine/6000.6/script-reference/unityengine/renderer.md) that has 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.

Additional Resources: [Mesh.subMeshCount](/engine/6000.6/script-reference/unityengine/mesh/submeshcount.md).

## GetTriangles(int, int, bool)

Fetches the triangle list for the specified sub-mesh on this object.

```csharp
public int[] GetTriangles(int submesh, int meshLod, bool applyBaseVertex)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The sub-mesh index. See [Mesh.subMeshCount](/engine/6000.6/script-reference/unityengine/mesh/submeshcount.md).**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The Mesh LOD index. Use -1 to get triangles for the entire sub-mesh including all levels of detail.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): True (default value) will apply base vertex offset to returned indices.

### Returns

| Type                                                           | Description |
| -------------------------------------------------------------- | ----------- |
| [int\[\]](https://learn.microsoft.com/dotnet/api/system.int32) |             |

### 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](/engine/6000.6/script-reference/unityengine/mesh/vertices.md) and [Mesh.GetVertices](/engine/6000.6/script-reference/unityengine/mesh/getvertices.md). 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](/engine/6000.6/script-reference/unityengine/material.md). When the Mesh is used with a [Renderer](/engine/6000.6/script-reference/unityengine/renderer.md) that has 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.

Additional Resources: [Mesh.subMeshCount](/engine/6000.6/script-reference/unityengine/mesh/submeshcount.md).

## GetTriangles(List\<int>, int)

Fetches the triangle list for the specified sub-mesh on this object.

```csharp
public void GetTriangles(List<int> triangles, int submesh)
```

### Parameters

**** (\[List\<int>]\(https\://learn.microsoft.com/dotnet/api/system.collections.generic.list-1)): A list of vertex indices to populate. Any existing items in the list are replaced.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The sub-mesh index. See [Mesh.subMeshCount](/engine/6000.6/script-reference/unityengine/mesh/submeshcount.md).

### 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](/engine/6000.6/script-reference/unityengine/mesh/vertices.md) and [Mesh.GetVertices](/engine/6000.6/script-reference/unityengine/mesh/getvertices.md). 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](/engine/6000.6/script-reference/unityengine/material.md). When the Mesh is used with a [Renderer](/engine/6000.6/script-reference/unityengine/renderer.md) that has 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.

Additional Resources: [Mesh.subMeshCount](/engine/6000.6/script-reference/unityengine/mesh/submeshcount.md).

## GetTriangles(List\<int>, int, bool)

Fetches the triangle list for the specified sub-mesh on this object.

```csharp
public void GetTriangles(List<int> triangles, int submesh, bool applyBaseVertex)
```

### Parameters

**** (\[List\<int>]\(https\://learn.microsoft.com/dotnet/api/system.collections.generic.list-1)): A list of vertex indices to populate. Any existing items in the list are replaced.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The sub-mesh index. See [Mesh.subMeshCount](/engine/6000.6/script-reference/unityengine/mesh/submeshcount.md).**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): 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](/engine/6000.6/script-reference/unityengine/mesh/vertices.md) and [Mesh.GetVertices](/engine/6000.6/script-reference/unityengine/mesh/getvertices.md). 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](/engine/6000.6/script-reference/unityengine/material.md). When the Mesh is used with a [Renderer](/engine/6000.6/script-reference/unityengine/renderer.md) that has 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.

Additional Resources: [Mesh.subMeshCount](/engine/6000.6/script-reference/unityengine/mesh/submeshcount.md).

## GetTriangles(List\<int>, int, int, bool)

Fetches the triangle list for the specified sub-mesh on this object.

```csharp
public void GetTriangles(List<int> triangles, int submesh, int meshLod, bool applyBaseVertex = true)
```

### Parameters

**** (\[List\<int>]\(https\://learn.microsoft.com/dotnet/api/system.collections.generic.list-1)): A list of vertex indices to populate. Any existing items in the list are replaced.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The sub-mesh index. See [Mesh.subMeshCount](/engine/6000.6/script-reference/unityengine/mesh/submeshcount.md).**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The Mesh LOD index. Use -1 to get triangles for the entire sub-mesh including all levels of detail.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): 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](/engine/6000.6/script-reference/unityengine/mesh/vertices.md) and [Mesh.GetVertices](/engine/6000.6/script-reference/unityengine/mesh/getvertices.md). 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](/engine/6000.6/script-reference/unityengine/material.md). When the Mesh is used with a [Renderer](/engine/6000.6/script-reference/unityengine/renderer.md) that has 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.

Additional Resources: [Mesh.subMeshCount](/engine/6000.6/script-reference/unityengine/mesh/submeshcount.md).

## GetTriangles(List\<ushort>, int, bool)

Fetches the triangle list for the specified sub-mesh on this object.

```csharp
public void GetTriangles(List<ushort> triangles, int submesh, bool applyBaseVertex = true)
```

### Parameters

**** (\[List\<ushort>]\(https\://learn.microsoft.com/dotnet/api/system.collections.generic.list-1)): A list of vertex indices to populate. Any existing items in the list are replaced.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The sub-mesh index. See [Mesh.subMeshCount](/engine/6000.6/script-reference/unityengine/mesh/submeshcount.md).**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): 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](/engine/6000.6/script-reference/unityengine/mesh/vertices.md) and [Mesh.GetVertices](/engine/6000.6/script-reference/unityengine/mesh/getvertices.md). 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](/engine/6000.6/script-reference/unityengine/material.md). When the Mesh is used with a [Renderer](/engine/6000.6/script-reference/unityengine/renderer.md) that has 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.

Additional Resources: [Mesh.subMeshCount](/engine/6000.6/script-reference/unityengine/mesh/submeshcount.md).

## GetTriangles(List\<ushort>, int, int, bool)

Fetches the triangle list for the specified sub-mesh on this object.

```csharp
public void GetTriangles(List<ushort> triangles, int submesh, int meshLod, bool applyBaseVertex = true)
```

### Parameters

**** (\[List\<ushort>]\(https\://learn.microsoft.com/dotnet/api/system.collections.generic.list-1)): A list of vertex indices to populate. Any existing items in the list are replaced.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The sub-mesh index. See [Mesh.subMeshCount](/engine/6000.6/script-reference/unityengine/mesh/submeshcount.md).**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The Mesh LOD index. Use -1 to get triangles for the entire sub-mesh including all levels of detail.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): 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](/engine/6000.6/script-reference/unityengine/mesh/vertices.md) and [Mesh.GetVertices](/engine/6000.6/script-reference/unityengine/mesh/getvertices.md). 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](/engine/6000.6/script-reference/unityengine/material.md). When the Mesh is used with a [Renderer](/engine/6000.6/script-reference/unityengine/renderer.md) that has 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.

Additional Resources: [Mesh.subMeshCount](/engine/6000.6/script-reference/unityengine/mesh/submeshcount.md).
