1
Fork 0
mirror of https://github.com/Steffo99/gravity-fusion.git synced 2024-11-24 17:24:19 +00:00
gravity-fusion/Assets/Components/ZoomWithScrollWheel.cs

26 lines
600 B
C#
Raw Normal View History

2019-10-05 09:48:36 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(Camera))]
public class ZoomWithScrollWheel : MonoBehaviour
{
public float zoomMultiplier;
public string zoomAxisName;
2019-10-07 21:29:58 +00:00
protected Camera camera;
2019-10-05 09:48:36 +00:00
void Start()
{
camera = GetComponent<Camera>();
}
void Update()
{
2019-10-05 18:41:07 +00:00
float mouseWheel = Input.GetAxisRaw(zoomAxisName);
2019-10-05 09:48:36 +00:00
if(mouseWheel != 0) {
camera.orthographicSize = Mathf.Clamp(camera.orthographicSize - mouseWheel * zoomMultiplier, 0, float.PositiveInfinity);
}
}
}