SebastianLague

Refactor example

Nov 15th, 2017
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.45 KB | None | 0 0
  1. void Start () {
  2.     float scale = (transform.localScale.x + transform.localScale.y + transform.localScale.z) *0.3f;
  3.     Mesh mesh = gameObject.GetComponent<MeshFilter>().mesh;
  4.     Vector3[] peturbedVertices = new Vector3[mesh.vertices.Length];
  5.  
  6.     for (int i = 0; i < mesh.vertices.Length; i++) {
  7.         peturbedVertices[i] = mesh.vertices[i] + Random.onUnitSphere * .1f * scale;
  8.     }
  9.     mesh.vertices = peturbedVertices;
  10.     mesh.RecalculateNormals ();
  11. }
Advertisement
Add Comment
Please, Sign In to add comment