Why Does This Mesh Drawing Code Not Work?

I’m attempting to draw a box where the bounds for a Collider2D exists. The following code I believe should render it just fine, however it never does:

            Mesh mesh = GetComponent<MeshFilter>().mesh = new Mesh();
            mesh.name = "Toggle Zone Preview";

            Vector3[] vertices = new Vector3[]
            {
                new Vector3(MyCollider.bounds.min.x, MyCollider.bounds.min.y, 0f),
                new Vector3(MyCollider.bounds.max.x, MyCollider.bounds.min.y, 0f),
                new Vector3(MyCollider.bounds.max.x, MyCollider.bounds.max.y, 0f),
                new Vector3(MyCollider.bounds.min.x, MyCollider.bounds.max.y, 0f)
            };
            mesh.vertices = vertices;

            int[] triangles = new int[]{0, 1, 2, 0, 2, 3};
            mesh.triangles = triangles;

            mesh.RecalculateNormals();

Any pointers?

In the script you’ve postet, you are only creating a mesh but not calling anything to render it… You should add a Mesh filter and renderer to a gameobject and set the required values to render this mesh.

Ah ha! They were rendering backwards. Flipped the verts and now it displays - thank you!