Center Camera on Object & Fill Screen

I’m trying to figure out how to center my camera on an object’s center (NOT its pivot point) and pan/zoom so the object fills most of the frame. I’m having a couple of problems.

One is that the objects’ pivot points are all at their bottoms, Y=0, and some objects are tall and some short. So having the camera LookAt an object’s transform doesn’t work consistently. Also, some objects are small and some big, so there is no fixed distance or FOV that will fill the screen with all objects.

What I’ve done so far is have the camera LookAt an object, the tweak its position/rotation as necessary depending on the size of the object, which is on a case-by-case basis. This is getting to be cumbersome as I add more objects of different sizes. I need a way to find the (geometrical) center of an object and also its size via script. I know this can be done with colliders, but many of the objects’ colliders don’t correspond to the their geometry, so I’d have to add additional colliders just for centering the camera. Is there any other way to find an object’s center and size?

The Renderer component has a “bounds” variable. You should be able to use bounds.center and bounds.extents to achieve this.

That works for individual meshes. Anything with children would need to be combined into a single mesh.