当前位置:网站首页>Zoom through the mouse wheel

Zoom through the mouse wheel

2022-07-06 05:43:00 Python's path to immortality

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



public class Scroll : MonoBehaviour {

	void Update () {
        if (Input.GetAxis ("Mouse ScrollWheel")<0)// Move the mouse wheel forward 
        {
            if (Camera .main.fieldOfView <100)// When the camera is a perspective camera , Set a maximum magnification value 
            {
                Camera.main.fieldOfView += 5;// Slide once to move the lens forward 5
            }
            if (Camera .main.orthographicSize <20)// When the camera is an orthographic camera , Set a maximum magnification value 
            {
                Camera.main.orthographicSize += 0.5f;// Slide once to move the lens forward 0.5
            }
        }
        if (Input .GetAxis ("Mouse ScrollWheel")>0)// Mouse wheel backward stroke 
        {
            if (Camera .main.fieldOfView >5)
            {
                Camera.main.fieldOfView -= 5;
            }
            if (Camera .main.orthographicSize>1)
            {
                Camera.main.orthographicSize -= 0.5f;
            }
        }
	}
}

原网站

版权声明
本文为[Python's path to immortality]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202132041412751.html