# GetVertexAttributeOffset(VertexAttribute)

> Gets the offset within a vertex buffer stream of a given vertex data attribute on this MeshData.

## Definition

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

```csharp
public int GetVertexAttributeOffset(VertexAttribute attr)
```

### Parameters

**** (\[VertexAttribute]\(/engine/6000.6/script-reference/unityengine/rendering/vertexattribute)): The vertex data attribute to check for.

### Returns

| Type                                                       | Description                                                                        |
| ---------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The byte offset within a stream of the data attribute, or -1 if it is not present. |

### Remarks

This method returns the byte offset for a specific vertex attribute (like position, normal, or color) relative to the start of an individual vertex's data within the vertex buffer stream that contains that attribute.

Unity allows flexible vertex data layouts where attributes can be interleaved in a single stream (typically stream 0) or separated across multiple streams using [Mesh.MeshData.SetVertexBufferParams](/engine/6000.6/script-reference/unityengine/mesh/meshdata/setvertexbufferparams.md). This method automatically identifies which stream the specified `attr` resides in and calculates its byte offset from the beginning of a vertex element within that particular stream.

Knowing this offset is useful when you need to directly access or interpret raw vertex buffer data, for instance, when working with the [Mesh.MeshData](/engine/6000.6/script-reference/unityengine/mesh/meshdata.md) API or [GraphicsBuffer](/engine/6000.6/script-reference/unityengine/graphicsbuffer.md), as it allows you to pinpoint the start of the attribute's data within the correct buffer.

If you need to know the specific index of the stream containing the attribute, use [Mesh.MeshData.GetVertexAttributeStream](/engine/6000.6/script-reference/unityengine/mesh/meshdata/getvertexattributestream.md). To get the total size (stride) of a single vertex within the attribute's stream, use [Mesh.MeshData.GetVertexBufferStride](/engine/6000.6/script-reference/unityengine/mesh/meshdata/getvertexbufferstride.md), passing the stream index obtained from `GetVertexAttributeStream`.

Additional Resources: [Mesh.MeshData.GetVertexAttributeStream](/engine/6000.6/script-reference/unityengine/mesh/meshdata/getvertexattributestream.md), [Mesh.MeshData.vertexBufferCount](/engine/6000.6/script-reference/unityengine/mesh/meshdata/vertexbuffercount.md), [Mesh.MeshData.GetVertexBufferStride](/engine/6000.6/script-reference/unityengine/mesh/meshdata/getvertexbufferstride.md), [Mesh.GetVertexAttributeOffset](/engine/6000.6/script-reference/unityengine/mesh/getvertexattributeoffset.md).
