1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class MouseMiddleControlCamera : MonoBehaviour {
- [Header("相机视角的最小值")]
- [Range(0,100)]
- public float m_CameraFieldOfViewMin;
- [Header("相机视角的最大值")]
- [Range(0, 100)]
- public float m_CameraFieldOfViewMax;
- private void Awake()
- {
- m_CameraFieldOfViewMin = 15;
- m_CameraFieldOfViewMax = 100;
- }
-
- void Start () {
-
- }
-
-
- void Update () {
-
-
-
-
-
- if (Input.GetAxis("Mouse ScrollWheel") < 0)
- {
- if (Camera.main.fieldOfView <= m_CameraFieldOfViewMax)
- Camera.main.fieldOfView += 2;
- if (Camera.main.orthographicSize <= 10)
- Camera.main.orthographicSize += 1f;
- }
-
- if (Input.GetAxis("Mouse ScrollWheel") > 0)
- {
- if (Camera.main.fieldOfView > m_CameraFieldOfViewMin)
- Camera.main.fieldOfView -= 2;
- if (Camera.main.orthographicSize >= 1)
- Camera.main.orthographicSize -= 1f;
- }
- }
- }
|