unity mouse scroll to zoom script code example
Example: unity scroll zoom
int minZoom = 40;
int maxZoom = 70;
int zoomValue = 10;
Camera _cam;
void Awake() => _cam = Camera.main;
if (Input.mouseScrollDelta.y > 0)
{
_cam.fieldOfView = Mathf.Clamp(_cam.fieldOfView -= zoomValue, minZoom, maxZoom);
}
else if (Input.mouseScrollDelta.y < 0)
{
_cam.fieldOfView = Mathf.Clamp(_cam.fieldOfView += zoomValue, minZoom, maxZoom);
}