title: Unity 2d mesh triangle
body: <p>I am a beginner at Unity. I want to create a triangle shape. Since I haven't found any pre-built triangle sprite. I tried using one with a mesh.</p>
  <p>This is the code:</p>
  <pre><code>public class meshgenerator : MonoBehaviour
  {
      // Start is called before the first frame update
      private float h = 10;
      private float my_base = 10;
      void Start()
      {
          Mesh mesh = new Mesh();
          Vector3[] vertices = new Vector3[3];
          vertices[0] = new Vector3(0, 0);
          vertices[1] = new Vector3(my_base, 0);
          vertices[2] = new Vector3(my_base / 2, h);
          mesh.vertices = vertices;
          mesh.triangles = new int[] {0, 1, 2 };
          GetComponent&lt;MeshFilter&gt;().mesh = mesh;
      }
  }
  </code></pre>
  <p>I didn't understand much from tutorials about meshes, but I think that the final shape should be made out of multiple triangles(a square would need 4 vertices and 2 triangles).</p>
  <p>Also, I don't know what UV helps with. Can anyone tell me why nothing is displayed when I run this code? I created an empty object, added MeshFilter, MeshRenderer, and this script to it.</p>
  <p>Thanks.</p>