-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSwipeDirectionEventTrigger.cs
41 lines (38 loc) · 1.13 KB
/
SwipeDirectionEventTrigger.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
using UnityUtility.Events;
namespace UnityUtility.EventTriggers
{
public class SwipeDirectionEventTrigger : SwipeEventTrigger
{
[Header("Events")]
public UnityEvent OnUpSwipe;
public UnityEvent OnDownSwipe;
public UnityEvent OnLeftSwipe;
public UnityEvent OnRightSwipe;
protected override void OnSwipeDetected(SwipeData swipe)
{
base.OnSwipeDetected(swipe);
switch (GetMoveDirection(swipe))
{
case MoveDirection.Up:
OnUpSwipe?.Invoke();
break;
case MoveDirection.Down:
OnDownSwipe?.Invoke();
break;
case MoveDirection.Left:
OnLeftSwipe?.Invoke();
break;
case MoveDirection.Right:
OnRightSwipe?.Invoke();
break;
default:
break;
}
}
}
}