-
Notifications
You must be signed in to change notification settings - Fork 1
/
DebuggableTouchReceiver.cs
49 lines (42 loc) · 1.34 KB
/
DebuggableTouchReceiver.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
42
43
44
45
46
47
48
49
using LC.Interaction;
using Lunity;
using UnityEngine;
using UnityEngine.InputSystem.LowLevel;
namespace LC.UI {
/// This class isn't necessary, a base TouchReceiver would be fine
/// This is just for testing in the editor
public class DebuggableTouchReceiver : TouchReceiver
{
[Header("Debug")]
public Vector3 DebugOffset;
private Vector3 _touchPosition;
private Vector3 _dragPosition;
[EditorButton]
public void DebugTouchDown()
{
_touchPosition = ThisTransform.position + Vector3.back;
_dragPosition = _touchPosition;
_dataOnTouch = new SpatialPointerState {
interactionPosition = _touchPosition,
inputDevicePosition = _touchPosition
};
OnTouchDown?.Invoke(_dataOnTouch);
}
[EditorButton]
public void DebugDrag()
{
_dragPosition += DebugOffset;
var data = new SpatialPointerState() {
interactionPosition = _dragPosition,
inputDevicePosition = _dragPosition,
startInteractionPosition = _touchPosition,
};
OnDrag?.Invoke(data);
}
[EditorButton]
private void DebugTouchUp()
{
OnTouchUp?.Invoke();
}
}
}