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?