Disable Autorotation

For example you designed your game to work in portrait mode only. But if you will rotate device when modal dialog like sharing or GameCenter, advertising will appear, or while it's on screen. The modal dialog can be switched to the landscape mode.

Point is that tying to lock aoturotation for the ViewControllers   like: SLComposeViewControllerGKAchievementViewControllerGKGameCenterViewController, ect. Can be very tricky, and so far I didn't found the way to do this depending on project setting on view controller creation phase.

As workaround you can lock autorotation in your AppDelegate. Open the builded XCode project and navigate to the UnityAppController.mm file

Navigate to the supportedInterfaceOrientationsForWindow method 

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window


and you can now lock rotation for all subviews here, for example if we want to use Portrait only mode we can change method code to looks like this:

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
    return UIInterfaceOrientationMaskPortrait;


or for supporting upside-down orientation as well, code will look like this:

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
    return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;


The original solution source can be found here.

Note: This is just a workaround, if you found better solution, feel free to contact us.