Created
May 12, 2022 06:09
-
-
Save junjanjon/2969bb90f5ce3205a746250b0b4b2c16 to your computer and use it in GitHub Desktop.
CreateUnityMesh.cs
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
var mesh = new Mesh | |
{ | |
vertices = new Vector3[] | |
{ | |
Vector3.zero, | |
Vector3.right, | |
Vector3.right + Vector3.back, | |
Vector3.back, | |
}, | |
uv = new Vector2[] | |
{ | |
new Vector2(0, 0), | |
new Vector2(1, 0), | |
new Vector2(1, 1), | |
new Vector2(0, 1), | |
}, | |
triangles = new int[] | |
{ | |
0, 1, 2, | |
2, 3, 0 | |
} | |
}; | |
gameObject.AddComponent<MeshFilter>().mesh = mesh; | |
gameObject.AddComponent<MeshRenderer>(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment