# SetSubMesh(int, SubMeshDescriptor, MeshUpdateFlags)

> Sets the data for a sub-mesh of the Mesh that Unity creates from the MeshData.

## Definition

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

```csharp
public void SetSubMesh(int index, SubMeshDescriptor desc, MeshUpdateFlags flags = MeshUpdateFlags.Default)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of the sub-mesh to set data for. See [subMeshCount](/engine/6000.0/script-reference/unityengine/mesh/meshdata/submeshcount.md). If you specify an out of range index, Unity throws an exception.**** (\[SubMeshDescriptor]\(/engine/6000.0/script-reference/unityengine/rendering/submeshdescriptor)): Sub-mesh data.**** (\[MeshUpdateFlags]\(/engine/6000.0/script-reference/unityengine/rendering/meshupdateflags)): Flags controlling the function behavior. See [MeshUpdateFlags](/engine/6000.0/script-reference/unityengine/rendering/meshupdateflags.md).

### Remarks

See [Mesh.SetSubMesh](/engine/6000.0/script-reference/unityengine/mesh/setsubmesh.md) for more information on setting sub-mesh data. If you call this method on a read-only MeshData, Unity throws an exception.
