# GetVertexAttributeStream(VertexAttribute)

> Gets the vertex buffer stream index of a specific vertex data attribute on this Mesh.

## Definition

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

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

### Parameters

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

### Returns

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

### Remarks

Meshes usually use a single vertex buffer stream, but it is possible to set up a vertex layout where attributes use different vertex buffers (see [Mesh.SetVertexBufferParams](/engine/6000.0/script-reference/unityengine/mesh/setvertexbufferparams.md)). When you use such a layout, use this function to query which vertex buffer stream a given attribute is part of.

Note that this function returns the index of the stream, without specifying where the attribute is within the stream. To identify the location of a given attribute in the stream, use [Mesh.GetVertexAttributeOffset](/engine/6000.0/script-reference/unityengine/mesh/getvertexattributeoffset.md).

```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 stream indices: 0, 0, 1
        Debug.Log($"Position stream {mesh.GetVertexAttributeStream(VertexAttribute.Position)}");
        Debug.Log($"Normal stream {mesh.GetVertexAttributeStream(VertexAttribute.Normal)}");
        Debug.Log($"Color stream {mesh.GetVertexAttributeStream(VertexAttribute.Color)}");

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

Additional Resources: [VertexAttribute](/engine/6000.0/script-reference/unityengine/rendering/vertexattribute.md), [Mesh.HasVertexAttribute](/engine/6000.0/script-reference/unityengine/mesh/hasvertexattribute.md), [Mesh.GetVertexAttributeOffset](/engine/6000.0/script-reference/unityengine/mesh/getvertexattributeoffset.md), [Mesh.vertexBufferCount](/engine/6000.0/script-reference/unityengine/mesh/vertexbuffercount.md), [Mesh.GetVertexBufferStride](/engine/6000.0/script-reference/unityengine/mesh/getvertexbufferstride.md).
