当前位置:网站首页>Zoom with unity mouse wheel: zoom the camera closer or farther

Zoom with unity mouse wheel: zoom the camera closer or farther

2022-07-06 20:13:00 LiPing122335

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class shuBiao : MonoBehaviour {

    void Update()
    {
        // Effect of mouse wheel
        if (Input.GetAxis("Mouse ScrollWheel") < 0)
        {
            if (Camera.main.fieldOfView <= 100)
                Camera.main.fieldOfView += 2;
            if (Camera.main.orthographicSize <= 20)
                Camera.main.orthographicSize += 0.5F;
        }
        //Zoom in
        if (Input.GetAxis("Mouse ScrollWheel") > 0)
        {
            if (Camera.main.fieldOfView > 2)
                Camera.main.fieldOfView -= 2;
            if (Camera.main.orthographicSize >= 1)
                Camera.main.orthographicSize -= 0.5F;
        }
    }
}
 

原网站

版权声明
本文为[LiPing122335]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202131232205800.html