# ApplyAndDisposeWritableMeshData

> Applies data defined in MeshData structs to Mesh objects.

## Definition

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

## ApplyAndDisposeWritableMeshData(MeshDataArray, Mesh, MeshUpdateFlags)

Applies data defined in `MeshData` structs to Mesh objects.

```csharp
public static void ApplyAndDisposeWritableMeshData(Mesh.MeshDataArray data, Mesh mesh, MeshUpdateFlags flags = MeshUpdateFlags.Default)
```

### Parameters

**** (\[MeshDataArray]\(/engine/6000.6/script-reference/unityengine/mesh/meshdataarray)): The mesh data array, see [Mesh.MeshDataArray](/engine/6000.6/script-reference/unityengine/mesh/meshdataarray.md).**** (\[Mesh]\(/engine/6000.6/script-reference/unityengine/mesh)): The destination Mesh. Mesh data array must be of size 1.**** (\[MeshUpdateFlags]\(/engine/6000.6/script-reference/unityengine/rendering/meshupdateflags)): The mesh data update flags, see [MeshUpdateFlags](/engine/6000.6/script-reference/unityengine/rendering/meshupdateflags.md).

### Remarks

ApplyAndDisposeWritableMeshData takes a [Mesh.MeshDataArray](/engine/6000.6/script-reference/unityengine/mesh/meshdataarray.md) containing writeable `MeshData` structs, and applies the vertex buffer, index buffer, and sub-mesh data to [Mesh](/engine/6000.6/script-reference/unityengine/mesh.md) objects. Use this to create new Meshes using the C# Job System and Burst.

After `ApplyAndDisposeWritableMeshData` is called, the `MeshDataArray` struct is disposed and can no longer be used.

Using this method, Unity performs very little data validation, so you must ensure your data is valid. In particular, you must ensure that the sub-mesh index range and topology are set to correct values. Sub-mesh indices, both indexStart and indexCount from [SubMeshDescriptor](/engine/6000.6/script-reference/unityengine/rendering/submeshdescriptor.md), must not overlap with any other sub-mesh indices.

When using Mesh LODs, you must also ensure that the provided index range for each of the sub-meshes is large enough to contain all levels of detail used within that sub-mesh. You can disable validation by setting flags to [MeshUpdateFlags.DontValidateLodRanges](/engine/6000.6/script-reference/unityengine/rendering/meshupdateflags/dontvalidatelodranges.md).

Additional Resources: [Mesh.AllocateWritableMeshData](/engine/6000.6/script-reference/unityengine/mesh/allocatewritablemeshdata.md), [Mesh.MeshDataArray](/engine/6000.6/script-reference/unityengine/mesh/meshdataarray.md), [Mesh.MeshData](/engine/6000.6/script-reference/unityengine/mesh/meshdata.md).

## ApplyAndDisposeWritableMeshData(MeshDataArray, Mesh\[], MeshUpdateFlags)

Applies data defined in `MeshData` structs to Mesh objects.

```csharp
public static void ApplyAndDisposeWritableMeshData(Mesh.MeshDataArray data, Mesh[] meshes, MeshUpdateFlags flags = MeshUpdateFlags.Default)
```

### Parameters

**** (\[MeshDataArray]\(/engine/6000.6/script-reference/unityengine/mesh/meshdataarray)): The mesh data array, see [Mesh.MeshDataArray](/engine/6000.6/script-reference/unityengine/mesh/meshdataarray.md).**** (\[Mesh\[]]\(/engine/6000.6/script-reference/unityengine/mesh)): The destination Meshes. Must match the size of mesh data array.**** (\[MeshUpdateFlags]\(/engine/6000.6/script-reference/unityengine/rendering/meshupdateflags)): The mesh data update flags, see [MeshUpdateFlags](/engine/6000.6/script-reference/unityengine/rendering/meshupdateflags.md).

### Remarks

ApplyAndDisposeWritableMeshData takes a [Mesh.MeshDataArray](/engine/6000.6/script-reference/unityengine/mesh/meshdataarray.md) containing writeable `MeshData` structs, and applies the vertex buffer, index buffer, and sub-mesh data to [Mesh](/engine/6000.6/script-reference/unityengine/mesh.md) objects. Use this to create new Meshes using the C# Job System and Burst.

After `ApplyAndDisposeWritableMeshData` is called, the `MeshDataArray` struct is disposed and can no longer be used.

Using this method, Unity performs very little data validation, so you must ensure your data is valid. In particular, you must ensure that the sub-mesh index range and topology are set to correct values. Sub-mesh indices, both indexStart and indexCount from [SubMeshDescriptor](/engine/6000.6/script-reference/unityengine/rendering/submeshdescriptor.md), must not overlap with any other sub-mesh indices.

When using Mesh LODs, you must also ensure that the provided index range for each of the sub-meshes is large enough to contain all levels of detail used within that sub-mesh. You can disable validation by setting flags to [MeshUpdateFlags.DontValidateLodRanges](/engine/6000.6/script-reference/unityengine/rendering/meshupdateflags/dontvalidatelodranges.md).

Additional Resources: [Mesh.AllocateWritableMeshData](/engine/6000.6/script-reference/unityengine/mesh/allocatewritablemeshdata.md), [Mesh.MeshDataArray](/engine/6000.6/script-reference/unityengine/mesh/meshdataarray.md), [Mesh.MeshData](/engine/6000.6/script-reference/unityengine/mesh/meshdata.md).

## ApplyAndDisposeWritableMeshData(MeshDataArray, List\<Mesh>, MeshUpdateFlags)

Applies data defined in `MeshData` structs to Mesh objects.

```csharp
public static void ApplyAndDisposeWritableMeshData(Mesh.MeshDataArray data, List<Mesh> meshes, MeshUpdateFlags flags = MeshUpdateFlags.Default)
```

### Parameters

**** (\[MeshDataArray]\(/engine/6000.6/script-reference/unityengine/mesh/meshdataarray)): The mesh data array, see [Mesh.MeshDataArray](/engine/6000.6/script-reference/unityengine/mesh/meshdataarray.md).**** (\[List\<Mesh>]\(https\://learn.microsoft.com/dotnet/api/system.collections.generic.list-1)): The destination Meshes. Must match the size of mesh data array.**** (\[MeshUpdateFlags]\(/engine/6000.6/script-reference/unityengine/rendering/meshupdateflags)): The mesh data update flags, see [MeshUpdateFlags](/engine/6000.6/script-reference/unityengine/rendering/meshupdateflags.md).

### Remarks

ApplyAndDisposeWritableMeshData takes a [Mesh.MeshDataArray](/engine/6000.6/script-reference/unityengine/mesh/meshdataarray.md) containing writeable `MeshData` structs, and applies the vertex buffer, index buffer, and sub-mesh data to [Mesh](/engine/6000.6/script-reference/unityengine/mesh.md) objects. Use this to create new Meshes using the C# Job System and Burst.

After `ApplyAndDisposeWritableMeshData` is called, the `MeshDataArray` struct is disposed and can no longer be used.

Using this method, Unity performs very little data validation, so you must ensure your data is valid. In particular, you must ensure that the sub-mesh index range and topology are set to correct values. Sub-mesh indices, both indexStart and indexCount from [SubMeshDescriptor](/engine/6000.6/script-reference/unityengine/rendering/submeshdescriptor.md), must not overlap with any other sub-mesh indices.

When using Mesh LODs, you must also ensure that the provided index range for each of the sub-meshes is large enough to contain all levels of detail used within that sub-mesh. You can disable validation by setting flags to [MeshUpdateFlags.DontValidateLodRanges](/engine/6000.6/script-reference/unityengine/rendering/meshupdateflags/dontvalidatelodranges.md).

Additional Resources: [Mesh.AllocateWritableMeshData](/engine/6000.6/script-reference/unityengine/mesh/allocatewritablemeshdata.md), [Mesh.MeshDataArray](/engine/6000.6/script-reference/unityengine/mesh/meshdataarray.md), [Mesh.MeshData](/engine/6000.6/script-reference/unityengine/mesh/meshdata.md).
