Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


SetVertexBufferData

Sets the data within a specific vertex buffer stream of the mesh's vertex buffer directly copied from data source.
Read time 5 minutesLast updated 4 days ago

Definition

  • Type: Method
  • Namespace: UnityEngine
  • 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.
public void SetVertexBufferData<T>(NativeArray<T> data, int dataStart, int meshBufferStart, int count, int stream = 0, MeshUpdateFlags flags = MeshUpdateFlags.Default) where T : struct

Parameters

The source data container from which the vertex data is copied.

dataStart

The first element in the source data to copy from.

meshBufferStart

The first element in mesh vertex buffer to receive the data.

count

The number of elements of type
T
to copy from the data container into the Mesh buffer.

stream

The vertex buffer stream to set data for. The default is 0. The value must be within the range 0 to 3.

The optional MeshUpdateFlags 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 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, Mesh.SetNormals, Mesh.SetUVs, or other attribute-specific methods instead.
{code Documentation/ManualDocs/com.unity.documentation-examples/Graphics/Scripts/Mesh/SetVertexBufferDataExample.cs}
Additional Resources: Mesh.SetVertexBufferParams, ::SetIndexBufferData, MeshUpdateFlags.

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.
public void SetVertexBufferData<T>(T[] data, int dataStart, int meshBufferStart, int count, int stream = 0, MeshUpdateFlags flags = MeshUpdateFlags.Default) where T : struct

Parameters

data

The source data container from which the vertex data is copied.

dataStart

The first element in the source data to copy from.

meshBufferStart

The first element in mesh vertex buffer to receive the data.

count

The number of elements of type
T
to copy from the data container into the Mesh buffer.

stream

The vertex buffer stream to set data for. The default is 0. The value must be within the range 0 to 3.

The optional MeshUpdateFlags 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 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, Mesh.SetNormals, Mesh.SetUVs, or other attribute-specific methods instead.
{code Documentation/ManualDocs/com.unity.documentation-examples/Graphics/Scripts/Mesh/SetVertexBufferDataExample.cs}
Additional Resources: Mesh.SetVertexBufferParams, ::SetIndexBufferData, MeshUpdateFlags.

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.
public void SetVertexBufferData<T>(List<T> data, int dataStart, int meshBufferStart, int count, int stream = 0, MeshUpdateFlags flags = MeshUpdateFlags.Default) where T : struct

Parameters

The source data container from which the vertex data is copied.

dataStart

The first element in the source data to copy from.

meshBufferStart

The first element in mesh vertex buffer to receive the data.

count

The number of elements of type
T
to copy from the data container into the Mesh buffer.

stream

The vertex buffer stream to set data for. The default is 0. The value must be within the range 0 to 3.

The optional MeshUpdateFlags 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 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, Mesh.SetNormals, Mesh.SetUVs, or other attribute-specific methods instead.
{code Documentation/ManualDocs/com.unity.documentation-examples/Graphics/Scripts/Mesh/SetVertexBufferDataExample.cs}
Additional Resources: Mesh.SetVertexBufferParams, ::SetIndexBufferData, MeshUpdateFlags.