- Mastering UI Development with Unity
- Ashley Godbold
- 351字
- 2021-08-27 18:43:10
Setting the orientation
When building for mobile devices, you can't specify resolution and aspect ratio. However, you can choose between screen orientations in mobile devices. There are two different orientations: Landscape and Portrait.
Games built so that they are wider than they are tall are said to have landscape resolution. Games build that are taller than they are wide are said to have portrait resolution. For example, a 16:9 aspect ratio would be a landscape resolution, and a 9:16 aspect ratio would be a portrait resolution, as illustrated:

So, while you can't choose the exact aspect ratio of a mobile game, you can choose the orientation, which forces the aspect ratio to be either wider or taller. You can set the orientation by navigating to Edit | Preferences | Player Settings and selecting the mobile device. If you are building for both iOS and Android, you will not have to set these properties for both. As you can see from the following screenshot, the asterisk next to the property of Default Orientation states that the settings are shared between multiple platforms:

You can set the Default Orientation to either Auto Rotation, or one of the other rotations, as shown:

Unity defines the following orientations as the following rotations:

When you select a rotation other than Auto Rotation as the Default Orientation, the game will only play at that orientation on the device. If you select Auto Rotation, you will have the option to select between multiple orientations:

In most cases, it is best to choose only the Landscape orientations or only the Portrait orientations, but not all four. Generally, allowing all four orientations will cause issues with the game's UI.
Players tend to prefer to be able to rotate their games (especially if they're like me and like to play games in bed while their phone is charging), so unless you have a good reason to stop rotation, it's best to enable both Portrait and Portrait Upside Down or Landscape Right and Landscape Left.
- Learning C# by Developing Games with Unity 2020
- Java高手真經(jīng)(高級(jí)編程卷):Java Web高級(jí)開(kāi)發(fā)技術(shù)
- SQL for Data Analytics
- C/C++常用算法手冊(cè)(第3版)
- UI智能化與前端智能化:工程技術(shù)、實(shí)現(xiàn)方法與編程思想
- MySQL數(shù)據(jù)庫(kù)管理與開(kāi)發(fā)實(shí)踐教程 (清華電腦學(xué)堂)
- C#程序設(shè)計(jì)基礎(chǔ):教程、實(shí)驗(yàn)、習(xí)題
- Learn React with TypeScript 3
- 琢石成器:Windows環(huán)境下32位匯編語(yǔ)言程序設(shè)計(jì)
- Python編程從0到1(視頻教學(xué)版)
- Linux Shell核心編程指南
- 深入剖析Java虛擬機(jī):源碼剖析與實(shí)例詳解(基礎(chǔ)卷)
- 計(jì)算機(jī)應(yīng)用基礎(chǔ)教程(Windows 7+Office 2010)
- Android傳感器開(kāi)發(fā)與智能設(shè)備案例實(shí)戰(zhàn)
- 機(jī)器學(xué)習(xí)微積分一本通(Python版)