Version: Unity 6 Preview (6000.0)
LanguageEnglish
  • C#

MeshGenerationContext.Allocate

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public UIElements.MeshWriteData Allocate(int vertexCount, int indexCount, Texture texture);

Parameters

vertexCount The number of vertices to allocate. The maximum is 65535 (or UInt16.MaxValue).
indexCount The number of triangle list indices to allocate. Each 3 indices represent one triangle, so this value should be multiples of 3.
texture An optional texture to be applied on the triangles allocated. Pass null to rely on vertex colors only.

Returns

MeshWriteData An object that gives access to the newely allocated data. If the returned vertex count is 0, then allocation failed (the system ran out of memory).

Description

Allocates and draws the specified number of vertices and indices required to express geometry for drawing the content of a VisualElement.

See Vertex.position for details on geometry generation conventions. If a valid texture was passed, then the returned MeshWriteData will also describe a rectangle for the UVs to use to sample the passed texture. This is needed because textures passed to this API can be internally copied into a larger atlas.