# SetIndexBufferParams(int, IndexFormat)

> Sets the index buffer size and format.

## Definition

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

```csharp
public void SetIndexBufferParams(int indexCount, IndexFormat format)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Size of index buffer.**** (\[IndexFormat]\(/engine/6000.7/script-reference/unityengine/rendering/indexformat)): Format of the indices.

### Remarks

Note: This method is designed for advanced users aiming for maximum performance because it operates on the underlying mesh data structures that primarily work on raw index buffers, vertex buffers and mesh subset data. Using this method, Unity performs very little data validation, so you must ensure your data is valid.

In particular, you must ensure that the index buffer does not contain out-of-bounds indices, and that the sub-mesh index range and bounds are updated via [Mesh.SetSubMesh](/engine/6000.7/script-reference/unityengine/mesh/setsubmesh.md).

For information about the difference between the simpler and more advanced methods of assigning data to a Mesh from script, see the notes on the [Mesh](/engine/6000.7/script-reference/unityengine/mesh.md) page.

General usage pattern is:

```csharp
var mesh = new Mesh();

// setup vertex buffer data
mesh.vertices = ...;

// set index buffer
mesh.SetIndexBufferParams(...);
mesh.SetIndexBufferData(...);

// setup information about mesh subsets
mesh.subMeshCount = ...;
mesh.SetSubMesh(index, ...);
```

When you change the index buffer size or format, the [Mesh.subMeshCount](/engine/6000.7/script-reference/unityengine/mesh/submeshcount.md) reverts to one, and the index buffer data is uninitialized. To set values, use [Mesh.SetIndexBufferData](/engine/6000.7/script-reference/unityengine/mesh/setindexbufferdata.md).

Note that changing [Mesh.subMeshCount](/engine/6000.7/script-reference/unityengine/mesh/submeshcount.md) to a smaller value than it was previously resizes the index buffer to be smaller. The new index buffer size is set to [SubMeshDescriptor.indexStart](/engine/6000.7/script-reference/unityengine/rendering/submeshdescriptor/indexstart.md) of the first removed sub-mesh.

If the index buffer size exceeds the maximum buffer size that the device supports, the method raises an exception. For more information, see [SystemInfo.maxGraphicsBufferSize](/engine/6000.7/script-reference/unityengine/systeminfo/maxgraphicsbuffersize.md).

Additional Resources: [Mesh.SetIndexBufferData](/engine/6000.7/script-reference/unityengine/mesh/setindexbufferdata.md), [Mesh.subMeshCount](/engine/6000.7/script-reference/unityengine/mesh/submeshcount.md), [Mesh.SetSubMesh](/engine/6000.7/script-reference/unityengine/mesh/setsubmesh.md), [Mesh.SetSubMeshes](/engine/6000.7/script-reference/unityengine/mesh/setsubmeshes.md).
