Unity Event not being invoked.

Hi all, I’m having trouble with what should be a fairly simple script to detect swipe movement. The event “onSwipe” is not invoked and I am unsure why. Any help would be greatly appreciated!

using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;

public enum SwipeDirection
{
    Left,
    Right,
    Up,
    Down
}

public class SwipeManager : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
{
    [System.Serializable]
    public class SwipeEvent : UnityEvent<SwipeDirection> { }

    [System.Serializable]
    public struct Events
    {
#pragma warning disable 649
        [SerializeField]
        private SwipeEvent _onSwipe;
        public SwipeEvent onSwipe
        {
            get { return _onSwipe; }
        }
#pragma warning restore 649
    }

    public float minimumSwipeDistance;
    public Events events;

    public void OnBeginDrag(PointerEventData eventData)
    {
    }

    public void OnDrag(PointerEventData eventData)
    {
    }

    public void OnEndDrag(PointerEventData eventData)
    {
        Vector3 dragVectorDirection = (eventData.position - eventData.pressPosition).normalized;
        float distance = Vector3.Distance(eventData.pressPosition, eventData.position);
        if (distance >= minimumSwipeDistance)
        {
            SwipeDirection direction = Direction(dragVectorDirection);
            events.onSwipe.Invoke(direction);
        }
    }

    private SwipeDirection Direction(Vector3 dragVector)
    {
        float positiveX = Mathf.Abs(dragVector.x);
        float positiveY = Mathf.Abs(dragVector.y);
        SwipeDirection draggedDir;
        if (positiveX > positiveY)
        {
            draggedDir = (dragVector.x > 0) ? SwipeDirection.Right : SwipeDirection.Left;
        }
        else
        {
            draggedDir = (dragVector.y > 0) ? SwipeDirection.Up : SwipeDirection.Down;
        }

        return draggedDir;
    }
}

I modified my script slightly, and my events still aren’t firing. The most annoying this is the debugs are called… I really am pulling my hair our over this one…

using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;

public enum SwipeDirection
{
    Left,
    Right,
    Up,
    Down
}

public class SwipeManager : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
{
    public float minimumSwipeDistance;

    public UnityEvent OnSwipeLeft;
    public UnityEvent OnSwipeRight;
    public UnityEvent OnSwipeUp;
    public UnityEvent OnSwipeDown;

    public void OnBeginDrag(PointerEventData eventData)
    {
    }

    public void OnDrag(PointerEventData eventData)
    {
    }

    public void OnEndDrag(PointerEventData eventData)
    {
        Vector3 dragVectorDirection = (eventData.position - eventData.pressPosition).normalized;
        float distance = Vector3.Distance(eventData.pressPosition, eventData.position);

        if (distance > minimumSwipeDistance)
        {
            TriggerMoveEvent(dragVectorDirection);
        }
        else
        {
            Debug.Log("Swipe below minimum threshold");
        }
    }

    private void TriggerMoveEvent(Vector3 dragVector)
    {
        float positiveX = Mathf.Abs(dragVector.x);
        float positiveY = Mathf.Abs(dragVector.y);

        SwipeDirection draggedDir;

        if (positiveX > positiveY)
        {
            draggedDir = (dragVector.x > 0) ? SwipeDirection.Right : SwipeDirection.Left;
        }
        else
        {
            draggedDir = (dragVector.y > 0) ? SwipeDirection.Up : SwipeDirection.Down;
        }

        switch (draggedDir)
        {
            case SwipeDirection.Left:
                Debug.Log("Left Swipe");
                OnSwipeLeft.Invoke();
                break;
            case SwipeDirection.Right:
                Debug.Log("Right Swipe");
                OnSwipeRight.Invoke();
                break;
            case SwipeDirection.Up:
                Debug.Log("Up Swipe");
                OnSwipeUp.Invoke();
                break;
            case SwipeDirection.Down:
                Debug.Log("Down Swipe");
                OnSwipeDown.Invoke();
                break;
            default:
                break;
        }
    }
}