Без опису
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #if PLATFORM_IOS || PLATFORM_VISIONOS
  2. #import "UnityView.h"
  3. #import "UnityAppController+Rendering.h"
  4. #include "OrientationSupport.h"
  5. @interface UnityView ()
  6. @property (nonatomic, readwrite) ScreenOrientation contentOrientation;
  7. @end
  8. @implementation UnityView (iOS)
  9. - (void)willRotateToOrientation:(UIInterfaceOrientation)toOrientation fromOrientation:(UIInterfaceOrientation)fromOrientation;
  10. {
  11. // to support the case of interface and unity content orientation being different
  12. // we will cheat a bit:
  13. // we will calculate transform between interface orientations and apply it to unity view orientation
  14. // you can still tweak unity view as you see fit in AppController, but this is what you want in 99% of cases
  15. ScreenOrientation to = ConvertToUnityScreenOrientation(toOrientation);
  16. ScreenOrientation from = ConvertToUnityScreenOrientation(fromOrientation);
  17. if (fromOrientation == UIInterfaceOrientationUnknown)
  18. _curOrientation = to;
  19. else
  20. _curOrientation = OrientationAfterTransform(_curOrientation, TransformBetweenOrientations(from, to));
  21. _viewIsRotating = YES;
  22. }
  23. - (void)didRotate
  24. {
  25. if (_shouldRecreateView)
  26. {
  27. [self recreateRenderingSurface];
  28. }
  29. _viewIsRotating = NO;
  30. }
  31. - (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event { UnitySendTouchesBegin(touches, event); }
  32. - (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event { UnitySendTouchesEnded(touches, event); }
  33. - (void)touchesCancelled:(NSSet*)touches withEvent:(UIEvent*)event { UnitySendTouchesCancelled(touches, event); }
  34. - (void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event { UnitySendTouchesMoved(touches, event); }
  35. @end
  36. #endif // PLATFORM_IOS || PLATFORM_VISIONOS