unity 通过滚轮放大缩小物体

using UnityEngine;
using System.Collections;

public class ca : MonoBehaviour {

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {
    if (Input.GetAxis("Mouse ScrollWheel") < 0)//滚轮向后 Camera.main.fieldOfView若小于80  则增加  fieldOfView是Camera中的一个属性
    {
        if (Camera.main.fieldOfView <= 80)
        {
            Camera.main.fieldOfView += 1;
        }
    }


    if (Input.GetAxis("Mouse ScrollWheel") > 0)//滚轮向前  Camera.main.fieldOfView若大于20   则减小
    {
        if (Camera.main.fieldOfView >=20)
        {
            Camera.main.fieldOfView -= 1;
        }
    }
}

}

你可能感兴趣的:(unity)