-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathZoomScriptMomentum.cs
62 lines (58 loc) · 1.68 KB
/
ZoomScriptMomentum.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ZoomScriptMomentum : MonoBehaviour
{
public Camera cam;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetAxis("Mouse ScrollWheel") < 0)
{
if (cam.orthographic == true) //if cam is orthographic
{
float currentSize = cam.orthographicSize;
float newSize = currentSize + 0.5f;
if (newSize < 50) //maximum effective field of view
{
cam.orthographicSize = newSize;
}
}
//else it is perspective
else
{
float current_fov = cam.fieldOfView;
float new_fov = current_fov += 1f;
if (new_fov < 70)
{
cam.fieldOfView = new_fov;
}
}
}
else if (Input.GetAxis("Mouse ScrollWheel") > 0)
{
if (cam.orthographic == true)
{
float currentSize = cam.orthographicSize;
float newSize = currentSize - 0.5f;
if (newSize > 5) //minimum effective field of view
{
cam.orthographicSize = newSize;
}
}
else
{
float current_fov = cam.fieldOfView;
float new_fov = current_fov -= 1f;
if (new_fov > 20)
{
cam.fieldOfView = new_fov;
}
}
}
}
}