UnityView.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. // in here we will go through subviews and call onUnityUpdateViewLayout selector (if present)
  18. // that allows to handle simple overlay child view layout without doing view controller magic
  19. - (void)layoutSubviews;
  20. - (void)recreateRenderingSurfaceIfNeeded;
  21. - (void)recreateRenderingSurface;
  22. // will match script-side Screen.orientation
  23. @property (nonatomic, readonly) ScreenOrientation contentOrientation;
  24. @end
  25. @interface UnityView (Deprecated)
  26. - (void)recreateGLESSurfaceIfNeeded __deprecated_msg("use recreateRenderingSurfaceIfNeeded instead.");
  27. - (void)recreateGLESSurface __deprecated_msg("use recreateRenderingSurface instead.");
  28. @end
  29. @interface UnityView (Keyboard)
  30. - (void)processKeyboard;
  31. @end
  32. @interface UnityView (UnityAppController)
  33. // if we know that unity view bounds have changed but need to update unity-side size/orientation immediately
  34. // otherwise the update will be delayed to next layoutSubviews
  35. - (void)boundsUpdated;
  36. @end
  37. #if PLATFORM_IOS || PLATFORM_VISIONOS
  38. #include "UnityView+iOS.h"
  39. #elif PLATFORM_TVOS
  40. #include "UnityView+tvOS.h"
  41. #endif
  42. void ReportSafeAreaChangeForView(UIView* view);
  43. // Computes safe area for a view in Unity coordinate system (origin of the view
  44. // is bottom-left, as compared to standard top-left)
  45. CGRect ComputeSafeArea(UIView* view);
  46. CGSize GetCutoutToScreenRatio();