Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void buildMesh()
- {
- Vector3[] vertices = new Vector3[4]; // For each corner
- Vector3[] normals = new Vector3[4]; // For lighting iirc
- int[] tris = new int[6]; // The vertices that make a triangle
- Mesh mesh = new Mesh();
- MeshRenderer meshRender = GetComponent<MeshRenderer>();
- MeshFilter meshFilter = GetComponent<MeshFilter>();
- //If Mesh renderer is null gtfo
- if(meshRender == null)
- {
- //We fucked up mayne
- return;
- }
- // if Mesh Filter is null gtfo
- if(meshFilter == null)
- {
- //We fucked up mayne
- return;
- }
- vertices[0] = new Vector3(0, 0 , 0); // Left top vert
- vertices[1] = new Vector3(1, 0, 0); // Right top vert
- vertices[2] = new Vector3(0, 0, -1); // left bottom vert
- vertices[3] = new Vector3(1, 0, -1); // right bottom vert
- //Left Triangle
- tris[0] = 0; // vert 0
- tris[1] = 3; // vert 3
- tris[2] = 2; // vert 2
- //Right triangle
- tris[3] = 0; // vert 0
- tris[4] = 1; // vert 1
- tris[5] = 3; // vert 3
- //Iirc light should happen on top
- normals[0] = Vector3.up;
- normals[1] = Vector3.up;
- normals[2] = Vector3.up;
- normals[3] = Vector3.up;
- mesh.vertices = vertices; // Set the mesh's vertices to what we made
- mesh.triangles = tris; // Set the triangles to " ".
- mesh.normals = normals; // set the normals to " ".
- meshFilter.mesh = mesh; // Set the mesh filter's mesh to the mesh we made
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement