Legacy Documentation: Version 2018.1 (Go to current version)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Mesh.vertices

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
public var vertices: Vector3[];
public Vector3[] vertices;

Description

Returns a copy of the vertex positions or assigns a new vertex positions array.

The number of vertices in the Mesh is changed by assigning a vertex array with a different number of vertices. Note that if you resize the vertex array then all other vertex attributes (normals, colors, tangents, UVs) are automatically resized too. RecalculateBounds is automatically invoked if no vertices have been assigned to the Mesh when setting the vertices.

function Update () {
    var mesh : Mesh = GetComponent.<MeshFilter>().mesh;
    var vertices : Vector3[] = mesh.vertices;

for (var i = 0; i < vertices.Length; i++) vertices[i] += Vector3.up * Time.deltaTime;

// assign the local vertices array into the vertices array of the Mesh. mesh.vertices = vertices; mesh.RecalculateBounds(); }
no example available in C#

Note: To make changes to the vertices it is important to copy the vertices from the Mesh. Once the vertices have been copied and changed the vertices can be reassigned back to the Mesh.

对文档有任何疑问,请移步至开发者社区提问,我们将尽快为您解答