UnityView+tvOS.mm 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #if PLATFORM_TVOS
  2. #import "UnityView.h"
  3. #include "iphone_Sensors.h"
  4. @implementation UnityView (tvOS)
  5. - (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
  6. {
  7. #if UNITY_TVOS_SIMULATOR_FAKE_REMOTE
  8. ReportSimulatedRemoteTouchesBegan(self, touches);
  9. #endif
  10. if (UnityGetAppleTVRemoteTouchesEnabled())
  11. UnitySendTouchesBegin(touches, event);
  12. }
  13. - (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event
  14. {
  15. #if UNITY_TVOS_SIMULATOR_FAKE_REMOTE
  16. ReportSimulatedRemoteTouchesEnded(self, touches);
  17. #endif
  18. if (UnityGetAppleTVRemoteTouchesEnabled())
  19. UnitySendTouchesEnded(touches, event);
  20. }
  21. - (void)touchesCancelled:(NSSet*)touches withEvent:(UIEvent*)event
  22. {
  23. #if UNITY_TVOS_SIMULATOR_FAKE_REMOTE
  24. ReportSimulatedRemoteTouchesEnded(self, touches);
  25. #endif
  26. if (UnityGetAppleTVRemoteTouchesEnabled())
  27. UnitySendTouchesCancelled(touches, event);
  28. }
  29. - (void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event
  30. {
  31. #if UNITY_TVOS_SIMULATOR_FAKE_REMOTE
  32. ReportSimulatedRemoteTouchesMoved(self, touches);
  33. #endif
  34. if (UnityGetAppleTVRemoteTouchesEnabled())
  35. UnitySendTouchesMoved(touches, event);
  36. }
  37. #if UNITY_TVOS_SIMULATOR_FAKE_REMOTE
  38. - (void)pressesBegan:(NSSet<UIPress*>*)presses withEvent:(UIEvent*)event
  39. {
  40. for (UIPress *press in presses)
  41. ReportSimulatedRemoteButtonPress(press.type);
  42. }
  43. - (void)pressesEnded:(NSSet<UIPress*>*)presses withEvent:(UIEvent*)event
  44. {
  45. for (UIPress *press in presses)
  46. ReportSimulatedRemoteButtonRelease(press.type);
  47. }
  48. #endif
  49. @end
  50. #endif // PLATFORM_TVOS