UDN
Search public documentation:

MobileScreenOrientation
日本語訳
中国翻译
한국어

Interested in the Unreal Engine?
Visit the Unreal Technology site.

Looking for jobs and company info?
Check out the Epic games site.

Questions about support via UDN?
Contact the UDN Staff

UE3 Home > Mobile Home > Mobile Screen Orientation

Mobile Screen Orientation


Overview


Mobile devices generally offer two screen orientations: portrait and landscape. When the device is held with the longer dimension vertically, this is portrait mode. Landscape mode refers to when the longer dimension is horizontal.

portrait.jpg landscape.jpg
Portrait Landscape

Games made with Unreal Engine 3 can be designed for either orientation, but must play in either portrait or landscape - not both - and the orientation cannot be changed during play.

Setting Orientation


Games made with Unreal Engine 3 default to displaying in landscape mode, but this can be modified if your game needs to be displayed in portrait mode.

Setting Orientation for iOS Devices

Screen orientation settings for iOS devices are in the .plist file. You can override the default orientation settings by adding your desired settings to the UDKGameOverrides.plist file in the UDKGame/Build/iPhone directory. There are 2 keys related to screen orientation: UIInterfaceOrientation and UISupportedInterfaceOrientations. UIInterfaceOrientation determines which orientation at start up, while UISupportedInterfaceOrientations specifies which orientations are allowed. UE3 only uses the UIInterfaceOrientation setting, but it is good practice to set both appropriately.

The valid values for these plist keys are:

portrait_up_th.jpg portrait_down_th.jpg landscape_right_th.jpg landscape_left_th.jpg
UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeRight UIInterfaceOrientationLandscapeLeft

To set your game to display in portrait mode, add the following to the UDKGameOverrides.plist file after the existing overrides:

<key>UIInterfaceOrientation</key>
<string>UIInterfaceOrientationPortrait</string>
<key>UISupportedInterfaceOrientations</key>
<array>
   <string>UIInterfaceOrientationPortrait</string>
    <string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>

The modified file should contain something like the following:

UDKGameOverrides.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
   <dict>
      <key>UIFileSharingEnabled</key>
      <true />
      <key>CFBundleIdentifier</key>
      <string>com.udn.example</string>
      <key>CFBundleName</key>
      <string>MyUDKGame</string>
      <key>CFBundleDisplayName</key>
      <string>UDK Game</string>
      <key>UIInterfaceOrientation</key>
      <string>UIInterfaceOrientationPortrait</string>
        <key>UISupportedInterfaceOrientations</key>
        <array>
          <string>UIInterfaceOrientationPortrait</string>
          <string>UIInterfaceOrientationPortraitUpsideDown</string>
        </array>
   </dict>
</plist>

Auto Rotation


As seen above, each orientation - portrait and landscape - has two variations depending on which way the device is being held. The default behavior of UE3 mobile games is to automatically rotate the screen between these two variations to match the device. This behavior is generally not an issue, but it can be problematic in the case of games that rely heavily on the tilt of the device for controlling gameplay. Two console commands are provided to control the auto-rotation behavior:

mobile enablerotation
Enables the auto-rotation behavior.
mobile disablerotation
Disables the auto-rotation behavior.

These commands can be executed in Kismet using a Console Command action to control the auto-rotation behavior on a per-map basis.

To start the map with auto-rotation disabled, the following Kismet could be used:

rotate_kismet.jpg

Or, the commands can be called through code using ConsoleCommand() function inherent to all actors. Executing these commands in the gametype or player controller would allow control of the auto-rotation behavior globally (or at least on a per-game basis).

This example demonstrates how to force auto-rotation off for a gametype:

MyGameInfo.uc
class MyGameInfo extends SimpleGame;

event InitGame(string Options, out string ErrorMessage)
{
   super.InitGame(Options, ErrorMessage);
   
   ConsoleCommand("mobile disablerotation");
}