-
Notifications
You must be signed in to change notification settings - Fork 0
/
DirPad.cs
24 lines (24 loc) · 849 Bytes
/
DirPad.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
using UnityEngine;
using UnityEngine.EventSystems;
public class DirPad : EventTrigger {
private Vector2 startPosition;
public bool dragging { get; private set; }
private Vector2 currentPosition;
public Vector2 dir { get { return currentPosition - startPosition; } }
public override void OnBeginDrag(PointerEventData eventData) {
base.OnBeginDrag(eventData);
startPosition = eventData.position;
dragging = true;
}
public override void OnDrag(PointerEventData eventData) {
base.OnDrag(eventData);
currentPosition = eventData.position;
}
public override void OnEndDrag(PointerEventData eventData) {
base.OnEndDrag(eventData);
dragging = false;
}
private void Update() {
//Debug.LogFormat("Dragging = {0}, Dir = {1}", dragging, dir);
}
}