UnityView.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #pragma once
  2. @interface UnityRenderingView : UIView
  3. {
  4. }
  5. + (void)InitializeForAPI:(UnityRenderingAPI)api;
  6. @end
  7. @interface UnityView : UnityRenderingView
  8. {
  9. @private ScreenOrientation _curOrientation;
  10. @private BOOL _shouldRecreateView;
  11. @private BOOL _viewIsRotating;
  12. }
  13. // we take scale factor into account because gl backbuffer size depends on it
  14. - (id)initWithFrame:(CGRect)frame scaleFactor:(CGFloat)scale;
  15. - (id)initWithFrame:(CGRect)frame;
  16. - (id)initFromMainScreen;
  17. - (void)resumeRendering;
  18. // in here we will go through subviews and call onUnityUpdateViewLayout selector (if present)
  19. // that allows to handle simple overlay child view layout without doing view controller magic
  20. - (void)layoutSubviews;
  21. - (void)recreateRenderingSurfaceIfNeeded;
  22. - (void)recreateRenderingSurface;
  23. // will match script-side Screen.orientation
  24. @property (nonatomic, readonly) ScreenOrientation contentOrientation;
  25. @property BOOL skipRendering;
  26. #if PLATFORM_IOS || PLATFORM_VISIONOS
  27. // state for the GCMouse indirect mouse path (see UnityView+iOS.mm)
  28. // true while the pointer is over this view; gates whether we forward scroll
  29. @property (nonatomic, assign) BOOL indirectPointerInside;
  30. // the scroll block we installed on GCMouse; teardown clears only this one
  31. @property (nonatomic, copy) id indirectScrollHandler;
  32. #endif
  33. @end
  34. @interface UnityView (Deprecated)
  35. - (void)recreateGLESSurfaceIfNeeded __deprecated_msg("use recreateRenderingSurfaceIfNeeded instead.");
  36. - (void)recreateGLESSurface __deprecated_msg("use recreateRenderingSurface instead.");
  37. @end
  38. @interface UnityView (Keyboard)
  39. - (void)processKeyboard;
  40. @end
  41. @interface UnityView (UnityAppController)
  42. - (void)boundsUpdated __deprecated_msg("use updateUnityBackbufferSize instead.");
  43. // if we know that unity view bounds have changed but we need to update unity-side size/orientation immediately
  44. - (void)updateUnityBackbufferSize;
  45. // update layer's drawableSize from bounds size: needed when bounds are changed (either by iOS or by us)
  46. - (void)updateLayerDrawableSizeFromBounds;
  47. @end
  48. #if PLATFORM_IOS || PLATFORM_VISIONOS
  49. #include "UnityView+iOS.h"
  50. #elif PLATFORM_TVOS
  51. #include "UnityView+tvOS.h"
  52. #endif
  53. void ReportSafeAreaChangeForView(UIView* view);
  54. // Computes safe area for a view in Unity coordinate system (origin of the view
  55. // is bottom-left, as compared to standard top-left)
  56. CGRect ComputeSafeArea(UIView* view);
  57. CGSize GetCutoutToScreenRatio();