Version: 2023.1
public Vector3[] vertices ;

描述

返回顶点位置的副本或分配新顶点位置数组。

The number of vertices in the Mesh is changed by assigning a vertex array with a different number of vertices.

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.

Note that this method returns the vertices in local space, not in world space.

using UnityEngine;

public class Example : MonoBehaviour { Mesh mesh; Vector3[] vertices; void Start() { mesh = GetComponent<MeshFilter>().mesh; vertices = mesh.vertices; }

void Update() { 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(); } }

**注意:**若要对 vertices 进行更改,从 Mesh 复制 顶点十分重要。复制和更改 vertices 之后,vertices 即可重新分配回 Mesh

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