# AllocateTempMesh

> Allocates the specified number of vertices and indices from a temporary allocator.

## Definition

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

## AllocateTempMesh(int, int, NativeSlice\<Vertex>, NativeSlice\<ushort>)

Allocates the specified number of vertices and indices from a temporary allocator.

```csharp
public void AllocateTempMesh(int vertexCount, int indexCount, out NativeSlice<Vertex> vertices, out NativeSlice<ushort> indices)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The number of vertices to allocate. The maximum is 65535 (or UInt16.MaxValue).**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The number of triangle list indices to allocate. Each 3 indices represent one triangle, so this value should be multiples of 3.**** (\[NativeSlice\<Vertex>]\(/engine/6000.6/script-reference/unity/collections/nativeslice1)): The returned vertices.**** (\[NativeSlice\<ushort>]\(/engine/6000.6/script-reference/unity/collections/nativeslice1)): The returned indices.

### Remarks

You can only call this method during the mesh generation phase of the panel and shouldn't use it beyond.

## AllocateTempMesh(ExtraVertexChannels, int, int, UIMesh)

Allocates a temporary [UIMesh](/engine/6000.6/script-reference/unityengine/uielements/uimesh.md) with mandatory vertex+index storage and one extras slice per channel set in `extraChannels`.

```csharp
public void AllocateTempMesh(ExtraVertexChannels extraChannels, int vertexCount, int indexCount, out UIMesh mesh)
```

### Parameters

**** (\[ExtraVertexChannels]\(/engine/6000.6/script-reference/unityengine/uielements/extravertexchannels)): **** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): **** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): **** (\[UIMesh]\(/engine/6000.6/script-reference/unityengine/uielements/uimesh)):&#x20;

### Remarks

Pass `vertexCount` = 0 to skip the vertex (and extras) allocation, or `indexCount` = 0 to skip the index allocation, so callers can mix-and-match (e.g. allocate indices once and reuse them across draws by stitching them into multiple [UIMesh](/engine/6000.6/script-reference/unityengine/uielements/uimesh.md) values).

Channels not requested are returned as default (empty) slices; the renderer treats those as "channel not provided" and zero-fills them at draw time. Use only during the mesh generation phase.
