MeshFilter.mesh Manual     Reference     Scripting  
Scripting > Runtime Classes > MeshFilter

var mesh : Mesh


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 () {
// Get instantiated mesh
var mesh : Mesh = GetComponent(MeshFilter).mesh;
// Randomly change vertices
var vertices = mesh.vertices;
for (var p in vertices)
p.y += Random.Range(-0.3, 0.3);
mesh.vertices = vertices;

See Also: Mesh class.