Mesh.vertices 网格顶点

var vertices : Vector3[]

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) will be automatically resized too. RecalculateBounds will automatically be invoked if no vertices have been assigned to the mesh when setting the vertices.

网格中顶点数量是通过赋予一个不同数量的顶点数组来改变。注意,如果你调整了顶点数组的大小,那么所有其他顶点的属性(法线,颜色,切线,纹理坐标)将自动地调节大小。在为顶点赋值时,如果这个网格的顶点有没有被赋值的那么RecalculateBounds将自动被调用。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	void Update() {
		Mesh mesh = GetComponent<MeshFilter>().mesh;
		Vector3[] vertices = mesh.vertices;
		int i = 0;
		while (i < vertices.Length) {
			vertices[i] += Vector3.up * Time.deltaTime;
			i++;
		}
		mesh.vertices = vertices;
		mesh.RecalculateBounds();
	}
}
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;

	mesh.vertices = vertices;
	mesh.RecalculateBounds();
}
Page last updated: 2010-12-9