# GetNativeIndexBufferPtr()

> Retrieves a native (underlying graphics API) pointer to the index buffer.

## Definition

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

```csharp
public IntPtr GetNativeIndexBufferPtr()
```

### Returns

| Type                                                           | Description                                          |
| -------------------------------------------------------------- | ---------------------------------------------------- |
| [IntPtr](https://learn.microsoft.com/dotnet/api/system.intptr) | Pointer to the underlying graphics API index buffer. |

### Remarks

Use this function to retrieve a pointer/handle corresponding to the Mesh index buffer, as it is represented in the native graphics API. This can be used to enable Mesh manipulation from [native code plugins](/engine/6000.0/manual/scripting/compilation-and-code-reload/plug-ins/native-plugin-interface.md).

Index buffer data is either 16 or 32 bit per index, depending on [Mesh.indexFormat](/engine/6000.0/script-reference/unityengine/mesh/indexformat.md). The layout of the index buffer otherwise depends on the [MeshTopology](/engine/6000.0/script-reference/unityengine/meshtopology.md) that is used (see [Mesh.SetIndices](/engine/6000.0/script-reference/unityengine/mesh/setindices.md)). The most common case is Meshes composed of triangle lists, which have index buffers with three indices per triangle.

The type of data returned depends on the underlying graphics API:

* ID3D11Buffer on D3D11

* ID3D12Resource on D3D12

* id\\\<MTLBuffer\\> on Metal

* buffer "name" (as GLuint) on OpenGL/ES

* internal representation on Vulkan, that should be accessed via IUnityGraphicsVulkan interface

For most use cases (when writing Mesh data from native code), you need to mark the Mesh as "dynamic" (see [Mesh.MarkDynamic](/engine/6000.0/script-reference/unityengine/mesh/markdynamic.md)) before getting the native buffer pointer. Generally this switches the buffers to be CPU-writable.

Note that calling this function when using multi-threaded rendering will synchronize with the rendering thread (a slow operation), so best practice is to set up necessary buffer pointers only at initialization time.

Additional Resources: [Native code plugins](/engine/6000.0/manual/scripting/compilation-and-code-reload/plug-ins/native-plugin-interface.md), [Mesh.GetNativeVertexBufferPtr](/engine/6000.0/script-reference/unityengine/mesh/getnativevertexbufferptr.md), [Mesh.SetIndices](/engine/6000.0/script-reference/unityengine/mesh/setindices.md).
