To check the distance you can use Raycast. You will need the RaycastHit to get the info on the distance.
The problem here is that the closest object may not be the object that takes up the most of the view of the camera. That would require some other calculation.