頂点の位置や、新しい頂点の位置の配列
メッシュに含まれる頂点の数は、頂点数が異なる頂点配列が指定されると変更されます。
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(); } }