Zoom camera to touch colliders

Hi everyone,

I have four colliders in the scene that define the bounds of the game area as shown below (colliders are the pink lines and the camera rect is the white box).
How can I zoom the camera out until one of its sides touches either the left or the right colliders? I was considering the option of using collision detection but could there be a better way that does not involve collision?

24880-camera.png

Thanks.

Here is what I did.

I have added the following script to the camera. The script zooms the camera out until one of the bounds is in the camera’s field of view then a flag is set off to stop the zooming.

public class ZoomOutCam : MonoBehaviour
{

    public GameObject boundObject;

    // flag to stop zooming 
    bool stopZooming = false;

    void Update()
    {
        if (boundObject.renderer.isVisible)
        {
            stopZooming = true;
        }
        if (!stopZooming)
        {
            Camera.main.orthographicSize += 0.1f;
        }
    }
}