# GetTopology(int)

> Retrieves the topology type of the specified submesh in the Mesh.

## Definition

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

```csharp
public MeshTopology GetTopology(int submesh)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of the submesh whose topology you want to retrieve. Submesh indices are zero-based, and the maximum index is Mesh.subMeshCount - 1.

### Returns

| Type                                                                        | Description                                                                                                                                                                                                            |
| --------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [MeshTopology](/engine/6000.7/script-reference/unityengine/meshtopology.md) | Returns the topology type of the specified submesh, as defined in the [MeshTopology](/engine/6000.7/script-reference/unityengine/meshtopology.md) enum. This value indicates how the submesh's vertices are connected. |

### Remarks

The topology specifies the geometric arrangement of vertices in a submesh and is determined when you assign data using the Mesh.SetIndices method. Common topology types include MeshTopology.Triangles, MeshTopology.Lines, and MeshTopology.Points, as defined in the [MeshTopology](/engine/6000.7/script-reference/unityengine/meshtopology.md) enum.

This method allows you to inspect the topology of a submesh at runtime, which can be helpful for debugging or procedural mesh generation. Ensure that the submesh index is within the valid range (0 ≤ submesh \< Mesh.subMeshCount) to avoid errors.

If no data has been assigned to the submesh, the default topology is MeshTopology.Triangles.

```csharp
using UnityEngine;

// Example that checks the topology of a submesh
public class MeshTopologyExample : MonoBehaviour
{
    void Start()
    {
        // Get the MeshFilter attached to this GameObject
        Mesh mesh = GetComponent<MeshFilter>().sharedMesh;

        // Iterate through submeshes and print their topology
        for (int submesh = 0; submesh < mesh.subMeshCount; submesh++)
        {
            MeshTopology topology = mesh.GetTopology(submesh);
            Debug.Log($"Submesh {submesh}: Topology = {topology}");
        }
    }
}
```

Additional Resources: [MeshTopology](/engine/6000.7/script-reference/unityengine/meshtopology.md) enum, [Mesh.SetIndices](/engine/6000.7/script-reference/unityengine/mesh/setindices.md) function.
