UnityViewControllerBase.mm 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #import "UnityViewControllerBase.h"
  2. #import "UnityAppController.h"
  3. #import "UnityAppController+ViewHandling.h"
  4. #import "PluginBase/UnityViewControllerListener.h"
  5. @implementation UnityViewControllerBase
  6. - (id)init
  7. {
  8. if ((self = [super init]))
  9. {
  10. #if PLATFORM_IOS
  11. AddViewControllerDefaultRotationHandling([UnityViewControllerBase class]);
  12. #endif
  13. }
  14. return self;
  15. }
  16. - (void)viewWillLayoutSubviews
  17. {
  18. [super viewWillLayoutSubviews];
  19. AppController_SendUnityViewControllerNotification(kUnityViewWillLayoutSubviews);
  20. }
  21. - (void)viewDidLayoutSubviews
  22. {
  23. [super viewDidLayoutSubviews];
  24. AppController_SendUnityViewControllerNotification(kUnityViewDidLayoutSubviews);
  25. }
  26. - (void)viewDidDisappear:(BOOL)animated
  27. {
  28. [super viewDidDisappear: animated];
  29. AppController_SendUnityViewControllerNotification(kUnityViewDidDisappear);
  30. }
  31. - (void)viewWillDisappear:(BOOL)animated
  32. {
  33. [super viewWillDisappear: animated];
  34. AppController_SendUnityViewControllerNotification(kUnityViewWillDisappear);
  35. }
  36. - (void)viewDidAppear:(BOOL)animated
  37. {
  38. [super viewDidAppear: animated];
  39. AppController_SendUnityViewControllerNotification(kUnityViewDidAppear);
  40. }
  41. - (void)viewWillAppear:(BOOL)animated
  42. {
  43. [super viewWillAppear: animated];
  44. AppController_SendUnityViewControllerNotification(kUnityViewWillAppear);
  45. }
  46. @end
  47. extern "C" void UnityNotifyAutoOrientationChange()
  48. {
  49. #if UNITY_SUPPORT_ROTATION
  50. [GetAppController() forceAutorotatingControllerToRefreshEnabledOrientationsIfNeeded];
  51. #endif
  52. }