SHARE
TWEET

Untitled

a guest Oct 22nd, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // GameObject -> Quad(Mesh Filter) + Mesh Renderer
  2. using UnityEngine;
  3.  
  4. public class MeshExample : MonoBehaviour {
  5.  
  6.   private void Start() {
  7.     Mesh mesh = new Mesh();
  8.    
  9.     Vector3[] vertices = new Vector3[3];
  10.     Vector2[] uv = new Vector2[3];
  11.     int[] triangles = new int[3];
  12.    
  13.     vertices[0] = new Vector3(0,0);
  14.     vertices[1] = new Vector3(0,100);
  15.     vertices[2] = new Vector3(100,0);
  16.    
  17.     uv[0] = new Vector2(0,0);
  18.     uv[1] = new Vector2(0,1);
  19.     uv[2] = new Vector2(1,1);
  20.    
  21.     // clockwise order
  22.     triangles[0] = 0;
  23.     triangles[1] = 1;
  24.     triangles[2] = 2;
  25.    
  26.     mesh.vertices = vertices;
  27.     mesh.uv = uv;
  28.     mesh.triangles = triangles;
  29.    
  30.    
  31.     GetComponent<MeshFilter>().mesh = mesh;
  32.   }
  33.    
  34. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top