Handling Orientation
If you are using an app with a portrait main menu and landscape gameplay, this article will help you understand how to make your application orientation work correctly with the OS UI.
This page is only needed if you have a game with landscape gameplay and plan to use a portrait main menu or have other views/scenes that render in portrait. If your game is designed for portrait-only or landscape-only, these instructions do not apply.
- Unity/C#
- Godot/GDScript
- iOS/Swift
- iOS/Objective-C
- Android
To make sure that the OS menu bar renders correctly, make sure that any UIViewControllers you use have their supportedInterfaceOrientations function declared. For example for a landscape view you would want to have the following:
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
and for the portrait view the view controller should have the following:
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
To make sure that the OS menu bar renders correctly, make sure that any UIViewControllers you use have their supportedInterfaceOrientations function overridden. For example for a landscape view you would want to have the following:
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.landscape
}
and for the portrait view the view controller should have the following:
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.portrait
}
The Android SDK works using Android Activities, defined in your manifest through skillz_game_activity and skillz_exit_activity. You are responsible for making sure that your activities are declared with your desired android:screenOrientation settings inside of the app's AndroidManifest.xml.
If you use a mix of landscape and portrait views (such as having a portrait main-menu and landscape in-game views) you can control the screen orientation by setting Screen.orientation. (Ex: a landscape view that uses Screen.orientation = ScreenOrientation.Landscape;).
You must allow for the portrait orientation from the Unity editor, then when transitioning to your gameplay, you will want to restrict the user from rotating into portrait while playing to prevent your UI from distorting.
Two settings govern orientation in a Godot game with Skillz, and for a single-orientation game they must agree:
- Project Settings > Display > Window > Handheld > Orientation controls your game's own orientation on device, as in any Godot project.
- Project Settings >
skillz/orientation("portrait"or"landscape") tells the Skillz SDK which orientation its own screens use. The export plugin injects it as the Androidskillz_orientationmeta-data and, on iOS, patches it into the Skillz framework's ownInfo.pliston everypod install. Godot does not cross-check the two values, so set them to the same orientation yourself.
If you mix orientations (a portrait main menu and landscape gameplay), switch at runtime with DisplayServer.screen_set_orientation(), for example DisplayServer.screen_set_orientation(DisplayServer.SCREEN_LANDSCAPE) when gameplay starts and back to DisplayServer.SCREEN_PORTRAIT when you return to your menu. Set skillz/orientation to the orientation your gameplay uses, since that is the orientation the Skillz match screens are designed around.
On iOS, DisplayServer.screen_set_orientation() has no effect unless Display > Window > Handheld > Orientation is set to Sensor (see DisplayServer). So for a mixed-orientation game set that project setting to Sensor, call screen_set_orientation() for each scene (including your menu, otherwise it follows the device), and keep skillz/orientation at your gameplay orientation. On Android the call works whatever the setting is.
On iOS the export plugin also widens your app's UISupportedInterfaceOrientations to admit both portrait and landscape. This is required: the Skillz Replay screen deliberately opens in the orientation opposite to gameplay so that two recordings fit side by side, and iOS will not rotate any presented screen into an orientation the app does not declare. This widening does not make your own scenes rotate; your game's orientation still comes from the Display settings above. On Android the SDK's own activities take their orientation from skillz_orientation; your Godot activity keeps the orientation from the Display settings.