-
기존의 vertex를 random으로 뒤튼다.
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] += vertices[i] * Random.Range(-100, 100)/100.0f * Time.deltaTime; } // assign the local vertices array into the vertices array of the Mesh. mesh.vertices = vertices; mesh.RecalculateBounds(); } }
using UnityEngine; public class Example : MonoBehaviour { Vector3[] newVertices; Vector2[] newUV; int[] newTriangles; void Start() { Mesh mesh = new Mesh(); GetComponent<MeshFilter>().mesh = mesh; mesh.vertices = newVertices; mesh.uv = newUV; mesh.triangles = newTriangles; } }
'Unity' 카테고리의 다른 글
Unity - UI Button (0) 2021.03.25 Unity - Prefabs (1) 2021.03.25 Unity - MonoBehaviour 생성 (0) 2021.03.25 Unity - Script Component얻기 (0) 2021.03.25 Unity - 튜플 리턴 타입(tuple return type) (0) 2021.03.22 Unity - Renderer.material 수정 (0) 2021.03.21 마우스로 Obj 튕겨 밀어내기 (0) 2021.03.21 Unity - Vector3 rotate (vector 회전) (0) 2021.03.20