# Unity detecting edge of mesh or end of mesh

I'm trying to create procedurally generated tiles and I've reached a point where I need to figure out the boundaries of the mesh or the outer vertices of the mesh.

    RaycastHit hit;
if (Physics.Raycast(bound[ i ].v2, Vector3.forward, out hit)) {
if (hit.distance > 2) {


I've tried raycasting all the vertices, but still can't get the vertices of the edge. The mesh does have a collider. any help on how i would go about this is appreciated, Thanks.

If your mesh will always be a rectangle you could use the MeshCollider, or more specifically MeshCollider.bounds.extents but that will only return 1/2 the width, length and height, not the vertices.