Skip to content

Instantly share code, notes, and snippets.

@junjanjon
Created May 12, 2022 06:09
Show Gist options
  • Save junjanjon/2969bb90f5ce3205a746250b0b4b2c16 to your computer and use it in GitHub Desktop.
Save junjanjon/2969bb90f5ce3205a746250b0b4b2c16 to your computer and use it in GitHub Desktop.
CreateUnityMesh.cs
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