25 lines
627 B
C#
25 lines
627 B
C#
using Godot;
|
|
|
|
public partial class ViewerCamera : Camera2D
|
|
{
|
|
private static readonly Vector2 ZoomMin = new(0.02001f, 0.02001f);
|
|
|
|
private static readonly Vector2 ZoomMax = new(4f, 4f);
|
|
public override void _Input(InputEvent @event)
|
|
{
|
|
if (@event is InputEventMouseButton eb)
|
|
{
|
|
if (eb.IsPressed())
|
|
{
|
|
if (eb.ButtonIndex == MouseButton.WheelDown)
|
|
if (Zoom.X > ZoomMin.X && Zoom.Y > ZoomMin.Y)
|
|
Zoom -= new Vector2(0.01f, 0.01f);
|
|
if(eb.ButtonIndex == MouseButton.WheelUp)
|
|
if (Zoom.X < ZoomMax.X && Zoom.Y < ZoomMax.Y)
|
|
Zoom += new Vector2(0.01f, 0.01f);
|
|
}
|
|
}
|
|
base._Input(@event);
|
|
}
|
|
}
|