Version: 2021.3
LanguageEnglish
  • C#

Mesh.GetIndices

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

Switch to Manual

Declaration

public int[] GetIndices(int submesh, bool applyBaseVertex = true);

Parameters

submesh The sub-mesh index. See subMeshCount.
applyBaseVertex True (default value) will apply base vertex offset to returned indices.

Returns

int[] Array with face indices.

Description

Fetches the index list for the specified sub-mesh.

Each integer in the returned list is a vertex index, which is used as an offset into the Mesh's vertex arrays. See vertices and GetVertices. The layout of the indices depends on the MeshTopology of the sub-mesh. For example, a triangular mesh will return indices in multiples of three.

A sub-mesh represents a list of triangles (or indices with a different MeshTopology) that are rendered using a single Material. When the Mesh is used with a Renderer that has multiple materials, you should ensure that there is one sub-mesh per Material.

Call the method overload with a List parameter if you control the life cycle of the index buffer and wish to avoid allocation of a new array with every access.

See Also: subMeshCount, GetTopology, MeshTopology enum, AcquireReadOnlyMeshData function.


Declaration

public void GetIndices(List<int> indices, int submesh, bool applyBaseVertex = true);

Declaration

public void GetIndices(List<ushort> indices, int submesh, bool applyBaseVertex);

Parameters

indices A list of indices to populate.
submesh The sub-mesh index. See subMeshCount.
applyBaseVertex True (default value) will apply base vertex offset to returned indices.

Description

Use this method overload if you control the life cycle of the list passed in and you want to avoid allocating a new array with every access.

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961