How do I adjust size of orthographic camera when moving the camera to a new view?

Spend some time thinking about why my view appears too zoomed in and chopped off when my camera moves from one object to another. I realized that it has to do with my main camera’s settings before moving the camera to another object.

My main camera is orthographic and the size is very small (1.3) so that I can view all of my complex object. When I click on a part of my complex object, the camera moves to a new view that’s far away to another object those scale is different than my complex object.

This view appears too zoomed and/or chopped off when I adjust the Z axis to try and fix it. However, it seems to be because of the size of my orthographic camera is set to 1.3 when it should be higher number for a normal view.

Now, I am just wondering how do I change the size of my main camera when my camera’s view changes to another object on mouse down?

Here’s the camera moving script:

using UnityEngine;
using System.Collections;

public class MoveCamToObject : MonoBehaviour {

public Camera mainCam;
 
void OnMouseUp() {

 mainCam.transform.position = new Vector3(-33, 241, 362); // These values I adjusted to an orthographic camera with size 90. 
 
   
}

}

I’m looking for a way to change the size in C#.

Hi,

I figured it out and I decided to post the solution so that it can help others too:

Camera.main.orthographicSize = 100; 

I put that script after my transform.position script.

Curious to see how other answers differ though (Perhaps, a non hard coded solution?)