mirror of
https://github.com/Steffo99/gravity-fusion.git
synced 2024-11-22 16:24:20 +00:00
28 lines
651 B
C#
28 lines
651 B
C#
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
|
|||
|
[RequireComponent(typeof(Camera))]
|
|||
|
public class ZoomWithScrollWheel : MonoBehaviour
|
|||
|
{
|
|||
|
[Header("Config")]
|
|||
|
public float zoomMultiplier;
|
|||
|
public string zoomAxisName;
|
|||
|
|
|||
|
[Header("References")]
|
|||
|
protected new Camera camera;
|
|||
|
|
|||
|
void Start()
|
|||
|
{
|
|||
|
camera = GetComponent<Camera>();
|
|||
|
}
|
|||
|
|
|||
|
void Update()
|
|||
|
{
|
|||
|
float mouseWheel = Input.GetAxis(zoomAxisName);
|
|||
|
if(mouseWheel != 0) {
|
|||
|
camera.orthographicSize = Mathf.Clamp(camera.orthographicSize - mouseWheel * zoomMultiplier, 0, float.PositiveInfinity);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|