# GetVertexBufferStride(int)

> Get vertex buffer stream stride in bytes.

## Definition

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

```csharp
public int GetVertexBufferStride(int stream)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Vertex data stream index to check for.

### Returns

| Type                                                       | Description                                                                     |
| ---------------------------------------------------------- | ------------------------------------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | Vertex data size in bytes in this stream, or zero if the stream is not present. |

### Remarks

Meshes usually use a single vertex buffer stream. But it is possible to setup a vertex layout where some attributes use different vertex buffers (see [Mesh.SetVertexBufferParams](/engine/6000.0/script-reference/unityengine/mesh/setvertexbufferparams.md), [VertexAttributeDescriptor](/engine/6000.0/script-reference/unityengine/rendering/vertexattributedescriptor.md)). You can use this function to query vertex data size in bytes within the given stream.

```csharp
using UnityEngine;
using UnityEngine.Rendering;

public class ExampleScript : MonoBehaviour
{
    void Start()
    {
        // Create a Mesh with custom vertex data layout:
        // position and normal go into stream 0,
        // color goes into stream 1.
        var mesh = new Mesh();
        mesh.SetVertexBufferParams(10,
            new VertexAttributeDescriptor(VertexAttribute.Position, VertexAttributeFormat.Float32, 3, stream:0),
            new VertexAttributeDescriptor(VertexAttribute.Normal, VertexAttributeFormat.Float32, 3, stream:0),
            new VertexAttributeDescriptor(VertexAttribute.Color, VertexAttributeFormat.UNorm8, 4, stream:1));

        // Prints 2 (two vertex streams)
        Debug.Log($"Vertex stream count: {mesh.vertexBufferCount}");
        // Next two lines print: 24 (12 bytes position + 12 bytes normal), 4 (4 bytes color)
        Debug.Log($"Steam 0 stride {mesh.GetVertexBufferStride(0)}");
        Debug.Log($"Steam 1 stride {mesh.GetVertexBufferStride(1)}");

        // Cleanup
        Object.DestroyImmediate(mesh);
    }
}
```

Additional Resources: [Mesh.vertexBufferCount](/engine/6000.0/script-reference/unityengine/mesh/vertexbuffercount.md), [Mesh.GetVertexAttributeOffset](/engine/6000.0/script-reference/unityengine/mesh/getvertexattributeoffset.md), [Mesh.SetVertexBufferParams](/engine/6000.0/script-reference/unityengine/mesh/setvertexbufferparams.md).
