You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
816 B
C#

using UnityEngine;
using UnityEngine.Events;
using MalbersAnimations.Events;
namespace MalbersAnimations
{
// [HelpURL("https://malbersanimations.gitbook.io/animal-controller/main-components/malbers-input")]
[AddComponentMenu("Malbers/Input/Mouse Scroll")]
public class MMouseScroll : MonoBehaviour
{
public UnityEvent OnScrollUp = new UnityEvent();
public UnityEvent OnScrollDown = new UnityEvent();
private float mousedelta = 0;
private void Update()
{
var newDelta = Input.mouseScrollDelta.y;
if (newDelta != mousedelta)
{
mousedelta = newDelta;
if (mousedelta < 0) OnScrollDown.Invoke();
else if (mousedelta > 0) OnScrollUp.Invoke();
}
}
}
}