summaryrefslogtreecommitdiff
path: root/Assets/ProFlares/DemoScripts/Zoom.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-04-21 21:52:56 +0800
committerchai <chaifix@163.com>2021-04-21 21:52:56 +0800
commit6d0c9a214dc0fda264e8588fa02aaa19b0b2cc5f (patch)
tree6a853a0b0cfb5818c864c3794cb58075876c07b0 /Assets/ProFlares/DemoScripts/Zoom.cs
+init
Diffstat (limited to 'Assets/ProFlares/DemoScripts/Zoom.cs')
-rw-r--r--Assets/ProFlares/DemoScripts/Zoom.cs47
1 files changed, 47 insertions, 0 deletions
diff --git a/Assets/ProFlares/DemoScripts/Zoom.cs b/Assets/ProFlares/DemoScripts/Zoom.cs
new file mode 100644
index 0000000..5caece9
--- /dev/null
+++ b/Assets/ProFlares/DemoScripts/Zoom.cs
@@ -0,0 +1,47 @@
+/// ProFlares - v1.08 - Copyright 2014-2015 All rights reserved - ProFlares.com
+
+/// <summary>
+/// Zoom.cs
+/// Attach to a transform, which will then move in on the Z Axis when the mouse wheel is used.
+/// </summary>
+using UnityEngine;
+using System.Collections;
+
+namespace ProFlares{
+ public class Zoom : MonoBehaviour {
+
+ Transform thisTrans;
+
+ public float current;
+
+ public float prev;
+
+ void Start () {
+ thisTrans = transform;
+ }
+
+ public float pos = 0;
+
+ public float dif;
+
+ public float offset;
+
+ void Update () {
+ prev = current;
+ current = Input.GetAxis("Mouse ScrollWheel");
+
+ if(Input.GetKey(KeyCode.UpArrow))
+ current = 0.1f;
+
+ if(Input.GetKey(KeyCode.DownArrow))
+ current = -0.1f;
+
+ dif = (prev-current)*-0.3f;
+ pos = Mathf.Clamp(pos + dif,-1f,1f);
+
+ Vector3 newPos = thisTrans.localPosition;
+ newPos.z = Mathf.Clamp(thisTrans.localPosition.z+current,-2f,3f);
+ thisTrans.localPosition = newPos;
+ }
+ }
+}