var MouseWheelSensitivity = 5;
var MouseZoomMin = 2;
vafloat; r MouseZoomMax = 10;
// 如果按住滑轮
if (Input.GetAxis("Mouse ScrollWheel") != 0)
{
//Debug.Log(Input.GetAxis("Mouse ScrollWheel"));
//Debug.Log(distance);
if (normalDistance >= MouseZoomMin && normalDistance <= MouseZoomMax)
{
normalDistance -= Input.GetAxis("Mouse ScrollWheel") * MouseWheelSensitivity;
}
if (normalDistance < MouseZoomMin)
{
normalDistance = MouseZoomMin;
}
if (normalDistance > MouseZoomMax)
{
normalDistance = MouseZoomMax;
}
}normalDistance 肯定有个初始值
可以百jjop度搜:编,程,回,忆,录,之,unity3d,都是从零基础开始讲解的
这个数值主要用于在 MouseZoomMin 与 MouseZoomMax 中运动限制的
即 normalDistance 不能小于 MouseZoomMin 数值,也不能大于 MouseZoomMax 数值
normalDistance 这个数值在鼠标滚轮滑动时不断变化的