# SetVertexBufferData

> Sets the data within a specific vertex buffer stream of the mesh's vertex buffer directly copied from data source.

## Definition

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

## SetVertexBufferData\<T>(NativeArray\<T>, int, int, int, int, MeshUpdateFlags)

Sets the data within a specific vertex buffer stream of the mesh's vertex buffer directly copied from data source.

```csharp
public void SetVertexBufferData<T>(NativeArray<T> data, int dataStart, int meshBufferStart, int count, int stream = 0, MeshUpdateFlags flags = MeshUpdateFlags.Default) where T : struct
```

### Parameters

**** (\[NativeArray\<T>]\(/engine/6000.7/script-reference/unity/collections/nativearray1)): The source data container from which the vertex data is copied.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The first element in the source data to copy from.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The first element in mesh vertex buffer to receive the data.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The number of elements of type `T` to copy from the data container into the Mesh buffer.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The vertex buffer stream to set data for. The default is 0. The value must be within the range 0 to 3.**** (\[MeshUpdateFlags]\(/engine/6000.7/script-reference/unityengine/rendering/meshupdateflags)): The optional [MeshUpdateFlags](/engine/6000.7/script-reference/unityengine/rendering/meshupdateflags.md) flags that control the update behavior of the mesh.

### Remarks

You can use `SetVertexBufferData` to set vertex data directly, without using format conversions for each vertex attribute. Elements are copied from the source container to the destination range within the mesh's vertex buffer.

This method does not update vertex attributes or vertex layout of the Mesh. You must configure the vertex buffer structure via [Mesh.SetVertexBufferParams](/engine/6000.7/script-reference/unityengine/mesh/setvertexbufferparams.md) before calling this method, defining the vertex count, layout, and which vertex streams to use.

This is a high-performance, low-level method for populating mesh vertex data. It provides direct access to the underlying vertex buffer with minimal validation or data conversion overhead, making it suitable for performance-critical scenarios where you need maximum control over mesh data.

For simpler ways to set vertex data that handle vertex attribute configuration automatically, use [Mesh.SetVertices](/engine/6000.7/script-reference/unityengine/mesh/setvertices.md), [Mesh.SetNormals](/engine/6000.7/script-reference/unityengine/mesh/setnormals.md), [Mesh.SetUVs](/engine/6000.7/script-reference/unityengine/mesh/setuvs.md), or other attribute-specific methods instead.

```csharp
{code Documentation/ManualDocs/com.unity.documentation-examples/Graphics/Scripts/Mesh/SetVertexBufferDataExample.cs}
```

Additional Resources: [Mesh.SetVertexBufferParams](/engine/6000.7/script-reference/unityengine/mesh/setvertexbufferparams.md), ::SetIndexBufferData, [MeshUpdateFlags](/engine/6000.7/script-reference/unityengine/rendering/meshupdateflags.md).

## SetVertexBufferData\<T>(\`\<>\[], int, int, int, int, MeshUpdateFlags)

Sets the data within a specific vertex buffer stream of the mesh's vertex buffer directly copied from data source.

```csharp
public void SetVertexBufferData<T>(T[] data, int dataStart, int meshBufferStart, int count, int stream = 0, MeshUpdateFlags flags = MeshUpdateFlags.Default) where T : struct
```

### Parameters

**** (\[\<T>\[]]\(./)): The source data container from which the vertex data is copied.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The first element in the source data to copy from.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The first element in mesh vertex buffer to receive the data.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The number of elements of type `T` to copy from the data container into the Mesh buffer.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The vertex buffer stream to set data for. The default is 0. The value must be within the range 0 to 3.**** (\[MeshUpdateFlags]\(/engine/6000.7/script-reference/unityengine/rendering/meshupdateflags)): The optional [MeshUpdateFlags](/engine/6000.7/script-reference/unityengine/rendering/meshupdateflags.md) flags that control the update behavior of the mesh.

### Remarks

You can use `SetVertexBufferData` to set vertex data directly, without using format conversions for each vertex attribute. Elements are copied from the source container to the destination range within the mesh's vertex buffer.

This method does not update vertex attributes or vertex layout of the Mesh. You must configure the vertex buffer structure via [Mesh.SetVertexBufferParams](/engine/6000.7/script-reference/unityengine/mesh/setvertexbufferparams.md) before calling this method, defining the vertex count, layout, and which vertex streams to use.

This is a high-performance, low-level method for populating mesh vertex data. It provides direct access to the underlying vertex buffer with minimal validation or data conversion overhead, making it suitable for performance-critical scenarios where you need maximum control over mesh data.

For simpler ways to set vertex data that handle vertex attribute configuration automatically, use [Mesh.SetVertices](/engine/6000.7/script-reference/unityengine/mesh/setvertices.md), [Mesh.SetNormals](/engine/6000.7/script-reference/unityengine/mesh/setnormals.md), [Mesh.SetUVs](/engine/6000.7/script-reference/unityengine/mesh/setuvs.md), or other attribute-specific methods instead.

```csharp
{code Documentation/ManualDocs/com.unity.documentation-examples/Graphics/Scripts/Mesh/SetVertexBufferDataExample.cs}
```

Additional Resources: [Mesh.SetVertexBufferParams](/engine/6000.7/script-reference/unityengine/mesh/setvertexbufferparams.md), ::SetIndexBufferData, [MeshUpdateFlags](/engine/6000.7/script-reference/unityengine/rendering/meshupdateflags.md).

## SetVertexBufferData\<T>(List\<T>, int, int, int, int, MeshUpdateFlags)

Sets the data within a specific vertex buffer stream of the mesh's vertex buffer directly copied from data source.

```csharp
public void SetVertexBufferData<T>(List<T> data, int dataStart, int meshBufferStart, int count, int stream = 0, MeshUpdateFlags flags = MeshUpdateFlags.Default) where T : struct
```

### Parameters

**** (\[List\<T>]\(https\://learn.microsoft.com/dotnet/api/system.collections.generic.list-1)): The source data container from which the vertex data is copied.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The first element in the source data to copy from.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The first element in mesh vertex buffer to receive the data.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The number of elements of type `T` to copy from the data container into the Mesh buffer.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The vertex buffer stream to set data for. The default is 0. The value must be within the range 0 to 3.**** (\[MeshUpdateFlags]\(/engine/6000.7/script-reference/unityengine/rendering/meshupdateflags)): The optional [MeshUpdateFlags](/engine/6000.7/script-reference/unityengine/rendering/meshupdateflags.md) flags that control the update behavior of the mesh.

### Remarks

You can use `SetVertexBufferData` to set vertex data directly, without using format conversions for each vertex attribute. Elements are copied from the source container to the destination range within the mesh's vertex buffer.

This method does not update vertex attributes or vertex layout of the Mesh. You must configure the vertex buffer structure via [Mesh.SetVertexBufferParams](/engine/6000.7/script-reference/unityengine/mesh/setvertexbufferparams.md) before calling this method, defining the vertex count, layout, and which vertex streams to use.

This is a high-performance, low-level method for populating mesh vertex data. It provides direct access to the underlying vertex buffer with minimal validation or data conversion overhead, making it suitable for performance-critical scenarios where you need maximum control over mesh data.

For simpler ways to set vertex data that handle vertex attribute configuration automatically, use [Mesh.SetVertices](/engine/6000.7/script-reference/unityengine/mesh/setvertices.md), [Mesh.SetNormals](/engine/6000.7/script-reference/unityengine/mesh/setnormals.md), [Mesh.SetUVs](/engine/6000.7/script-reference/unityengine/mesh/setuvs.md), or other attribute-specific methods instead.

```csharp
{code Documentation/ManualDocs/com.unity.documentation-examples/Graphics/Scripts/Mesh/SetVertexBufferDataExample.cs}
```

Additional Resources: [Mesh.SetVertexBufferParams](/engine/6000.7/script-reference/unityengine/mesh/setvertexbufferparams.md), ::SetIndexBufferData, [MeshUpdateFlags](/engine/6000.7/script-reference/unityengine/rendering/meshupdateflags.md).
