var mesh : Mesh
Description
Returns the instantiated Mesh assigned to the mesh filter.
If no mesh is assigned to the mesh filter a new mesh will be created and assigned.
If the mesh assigned to the mesh filter is shared, it will be automatically duplicated and the instantiated mesh will be returned.
By using mesh property you can modify the mesh for a single object only. The
other objects that used the same mesh will not be modified.
function Update () {
var mesh :
Mesh = GetComponent(MeshFilter).mesh;
var vertices :
Vector3[] = mesh.vertices;
for (
var p :
int = 0; p < vertices.Length; p++) {
vertices[p] +=
Vector3(0,
Random.Range(-0.3, 0.3), 0);
}
mesh.vertices = vertices;
mesh.RecalculateNormals();
}
using UnityEngine;
using System.Collections;
public class example :
MonoBehaviour {
void Update() {
Mesh mesh = GetComponent<MeshFilter>().mesh;
Vector3[] vertices = mesh.vertices;
int p = 0;
while (p < vertices.Length) {
vertices[p] +=
new Vector3(0,
Random.Range(-0.3F, 0.3F), 0);
p++;
}
mesh.vertices = vertices;
mesh.RecalculateNormals();
}
}
import UnityEngine
import System.Collections
class example(
MonoBehaviour):
def
Update():
mesh as
Mesh = GetComponent[of MeshFilter]().mesh
vertices as (
Vector3) = mesh.vertices
p as
int = 0
while p < vertices.Length:
vertices[p] +=
Vector3(0,
Random.Range(-0.3F, 0.3F), 0)
p++
mesh.vertices = vertices
mesh.RecalculateNormals()
See Also: Mesh class.