设置Camera的FOV属性实现:
按下镜头拉近,再按下拉远
逐渐拉近
缩放等级变化
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CareamZoom : MonoBehaviour
{
// Start is called before the first frame update
private Camera camera;
void Start()
{
camera = GetComponent<Camera>();
}
private bool isFar =true;
// Update is called once per frame
void Update()
{
plan1();
}
private void plan1()
{
if (Input.GetMouseButtonDown(1))
{
//拉远60
isFar = !isFar;
if (isFar)
{
camera.fieldOfView = 60;
}
//拉近20
else
camera.fieldOfView = 20;
}
}
private void plan2()
{
if (Input.GetMouseButtonDown(1))
{
//拉远60
isFar = !isFar;
if (isFar)