public bool canFocus = true ;
//You could play with the zoomValue in inspector in play mode
[Range(1f , 100f)]
public float zoomValue ;
private Camera _camera ;
void Start()
{
if (!_camera)
_camera = Camera.main ;
}
void Update()
{
if (canFocus)
{
//call the function from below as per your camera ;
}
}
//Orthographic projection is used for 2D games
void FocusInOrthographicView()
{
//See your Main Camera setting If the projection is set to Orthographic use this
_camera.orthographicSize = zoomValue ;
}
//Perspective projection is used for 3D games
void FocusInPerspectiveView()
{
//Is the projection is set to Perspective use this
_camera.fieldofView = zoomValue ;
}