Version: Unity 6.3 Beta (6000.3)
LanguageEnglish
  • C#

MeshTopology

enumeration

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

Description

Specifies how the indices in a mesh's index buffer are used to construct geometry.

Depending on the topology type, the combination of indices and vertices form shapes such as triangles, quads, lines, or points.

The most commonly used topology is MeshTopology.Triangles, as most hardware is optimized to render triangles efficiently. In meshes with multiple sub-meshes, the topology can be individually set for each sub-mesh.

This enum is commonly used in scripts to define geometry or create procedural meshes.

// This example demonstrates how to create a mesh with two sub-meshes, each using a distinct topology.
Mesh mesh = new Mesh();
mesh.vertices = new Vector3[]
{
    new Vector3(0, 0, 0),
    new Vector3(1, 0, 0),
    new Vector3(0, 1, 0),
    new Vector3(1, 1, 0),
};
mesh.subMeshCount = 2;
mesh.SetIndices(new int[] { 0, 2, 1 }, MeshTopology.Triangles, 1);
mesh.SetIndices(new int[] { 0, 2, 3, 1, 0 }, MeshTopology.LineStrip, 0);
mesh.RecalculateNormals();

Additional resources: Mesh, SubMeshDescriptor, Mesh.SetIndices.

Properties

Property Description
TrianglesConnects indices in groups of three to form triangular faces.
QuadsConnects indices in groups of four to form quadrilateral faces.
LinesConnects pairs of indices to form individual line segments.
LineStripConnects indices consecutively to form a single continuous line.
PointsInterprets indices as individual points without forming connected geometry.
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961