- Mastering UI Development with Unity
- Ashley Godbold
- 493字
- 2021-08-27 18:43:08
Changing the aspect ratio and resolution of the game view
You can easily switch between different resolutions and aspect ratios in the Game tab. This will allow you to see how your UI scales at the different resolutions and aspect ratios:
- If you navigate to your Game tab, you will see the words Free Aspect. Clicking on Free Aspect will reveal a menu that shows various aspect ratios and a single 1024x768 resolution that is labeled Standalone:

Free Aspect means that the window will scale to whatever resolution you set by changing the size of the game window. So by moving the frame around on the game window, you will change the aspect ratio. You can see this in effect easily by setting your Editor layout to one that shows both the Screen and Game tabs open simultaneously. For example, setting the Layout to 2 by 3 will do this.
- You can change the layout by selecting the word Default that appears in the upper-right hand corner of the Unity Editor.
- Now the Game and Scene tabs will both be visible on the left-hand side of your screen. Zoom out of your scene tab very far so that the square representing the camera looks small, as shown:

- Now, reduce the size of the game tab so that it is a very small thin rectangle. You will see that the main camera is now also displaying as a very small thin rectangle, because we are in Free Aspect ratio mode:
- You can select another aspect ratio, like 5:4, and you will see that as you rescale the game window, the blue area representing the actual game will maintain a 5:4 ratio and black bars to fill in any extra spacing. The camera will also maintain that ratio:

- Standalone (1024x768) will attempt to emulate the 1024x768 resolution. It's pretty likely that the window you have set for the Game tab is not big enough to support 1024x768 pixels; if so, it will be scaled as indicated in the following screenshot:

If the resolution or aspect ratio you want to use is not available in the resolution drop-down menu, you can add your own item to this menu by selecting the plus sign. If you want to create a set resolution item, set Type to Fixed Resolution. If you want to create a set aspect ratio item, set Type to Aspect Ratio:

For example, if I wanted to have a resolution item that represented the iPhone 6, add an item with the settings displayed in the following screenshot:

Once you hit OK, the iphone 6 item will be displayed at the bottom of the list. When you select it, the camera and visible area of the Game tab will maintain the aspect ratio created by a 1334x750 resolution:

- Linux C/C++服務器開發實踐
- Access 數據庫應用教程
- Java深入解析:透析Java本質的36個話題
- The DevOps 2.4 Toolkit
- 劍指大數據:企業級數據倉庫項目實戰(在線教育版)
- Microsoft 365 Certified Fundamentals MS-900 Exam Guide
- C語言程序設計習題與實驗指導
- FPGA嵌入式項目開發實戰
- Flink技術內幕:架構設計與實現原理
- Oracle Database XE 11gR2 Jump Start Guide
- Python編程入門(第3版)
- 編程風格:程序設計與系統構建的藝術(原書第2版)
- jQuery EasyUI從零開始學
- 測試架構師修煉之道:從測試工程師到測試架構師(第2版)
- Salt Cookbook