Answers for "unity scroll zoom"

C#
0

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);
}
Posted by: Guest on February-24-2021

C# Answers by Framework

Browse Popular Code Answers by Language