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

25 lines
604 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(Camera))]
public class ZoomWithScrollWheel : MonoBehaviour
{
public float zoomMultiplier;
public string zoomAxisName;
protected new Camera camera;
void Start()
{
camera = GetComponent<Camera>();
}
void Update()
{
float mouseWheel = Input.GetAxisRaw(zoomAxisName);
if(mouseWheel != 0) {
camera.orthographicSize = Mathf.Clamp(camera.orthographicSize - mouseWheel * zoomMultiplier, 0, float.PositiveInfinity);
}
}
}