Last active
October 25, 2015 07:42
-
-
Save FVSHaLuan/2c00c549188174dcf83e to your computer and use it in GitHub Desktop.
**Function: creating a mesh data for god's sake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
[RequireComponent(typeof(MeshFilter))] | |
[ExecuteInEditMode] | |
public class DumbMesh : MonoBehaviour | |
{ | |
void Start() | |
{ | |
GenerateMesh(); | |
} | |
void GenerateMesh() | |
{ | |
Mesh mesh = GetComponent<MeshFilter>().sharedMesh; | |
if (mesh == null) | |
{ | |
mesh = new Mesh(); | |
GetComponent<MeshFilter>().sharedMesh = mesh; | |
} | |
mesh.Clear(); | |
mesh.vertices = new Vector3[] | |
{ | |
new Vector3(-1,-1,0), | |
new Vector3(1,-1,0), | |
new Vector3(1,1,0), | |
new Vector3(-1,1,0), | |
}; | |
mesh.triangles = new int[] | |
{ | |
2,1,0, | |
3,2,0 | |
}; | |
mesh.uv = new Vector2[] | |
{ | |
new Vector3(0,0,0), | |
new Vector3(1,0,0), | |
new Vector3(1,1,0), | |
new Vector3(0,1,0), | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment