UnityView+tvOS.mm
1.53 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#if PLATFORM_TVOS
#import "UnityView.h"
#include "iphone_Sensors.h"
@implementation UnityView (tvOS)
- (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
{
#if UNITY_TVOS_SIMULATOR_FAKE_REMOTE
ReportSimulatedRemoteTouchesBegan(self, touches);
#endif
if (UnityGetAppleTVRemoteTouchesEnabled())
UnitySendTouchesBegin(touches, event);
}
- (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event
{
#if UNITY_TVOS_SIMULATOR_FAKE_REMOTE
ReportSimulatedRemoteTouchesEnded(self, touches);
#endif
if (UnityGetAppleTVRemoteTouchesEnabled())
UnitySendTouchesEnded(touches, event);
}
- (void)touchesCancelled:(NSSet*)touches withEvent:(UIEvent*)event
{
#if UNITY_TVOS_SIMULATOR_FAKE_REMOTE
ReportSimulatedRemoteTouchesEnded(self, touches);
#endif
if (UnityGetAppleTVRemoteTouchesEnabled())
UnitySendTouchesCancelled(touches, event);
}
- (void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event
{
#if UNITY_TVOS_SIMULATOR_FAKE_REMOTE
ReportSimulatedRemoteTouchesMoved(self, touches);
#endif
if (UnityGetAppleTVRemoteTouchesEnabled())
UnitySendTouchesMoved(touches, event);
}
#if UNITY_TVOS_SIMULATOR_FAKE_REMOTE
- (void)pressesBegan:(NSSet<UIPress*>*)presses withEvent:(UIEvent*)event
{
for (UIPress *press in presses)
ReportSimulatedRemoteButtonPress(press.type);
}
- (void)pressesEnded:(NSSet<UIPress*>*)presses withEvent:(UIEvent*)event
{
for (UIPress *press in presses)
ReportSimulatedRemoteButtonRelease(press.type);
}
#endif
@end
#endif // PLATFORM_TVOS