Looking for a quick way to surround stages with box colliders

I am currently making many stages for my game and am needing to manually surround the stages with box colliders. I need all sides to have colliders because of the type of game it is.

The stages can be all sorts of shapes but is 100% right angles. An example shape:

Any ideas on a clever way to surround something like this with box colliders at runtime?

7979568--1024329--upload_2022-3-20_14-22-20.png

How are you defining the shapes? Are they meshes?

A combination of meshes yes, they’re basically pipes, pretty much as pictured.

If the outside is always a rectangle you could do a boxcast from each direction to find the limit of that side. Assuming your meshes are somehow colliders. You’d end up with say, x0=5, x1=40, z0=-10, z1=20. So now you know the left wall should be at x=4.5 (assuming it’s 1 unit thick) and z=5 (average of the z’s) and at least 30 units wide (but I tend to simply make my border walls 100 units long, not worry about having them centered, and let the ends stick out super-far; so all I need is x=4.5, z=leave at 0).

Or you could run through the mesh points to get that same thing. Easy for one mesh which is always at 000, but if you have several in various spots you’ll need to add their positions (like M[2].position.x + M[2].verts*.x)*