お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
Closeメッシュフィルターに割り当てられた Mesh を返します
メッシュがメッシュフィルターに割り当てられていない場合、新しいメッシュが作成され割り当てられます。
メッシュがメッシュフィルターに割り当てられている場合は、 mesh
プロパティの初回の照会時に複製が作成され、コピーを
返します。 mesh
プロパティの更なる
代わりにMeshFilter.sharedMeshを使用してください、
/mesh/ プロパティを使用することによって、1つのオブジェクトのみのメッシュを変更することができます。
同じメッシュが使用されている他のオブジェクトは変更されません。
// Distortionates the mesh vertically. function Update () { // Get instantiated mesh var mesh : Mesh = GetComponent(MeshFilter).mesh; // Randomly change vertices 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 ExampleClass : 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 public class ExampleClass(MonoBehaviour): def Update() as void: 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 クラス