# 屏幕配置

> Contains information on screen-related features such as application orientation and multi-window mode.

Unity 提供的功能可用于在编辑器中和运行时配置屏幕。

## 屏幕方向##screen-orientation

可在 Android 设备上控制应用程序的屏幕方向。检测方向变化或强制使用特定方向对于创建一些取决于用户如何握持设备的行为很有用。

要检索当前应用程序方向，请访问 [Screen.orientation](/engine/6000.0/script-reference/unity-engine/screen/orientation.md) 属性。可用方向为：

| **方向**                 | **行为**                                |
| ---------------------- | ------------------------------------- |
| **Portrait**           | 应用程序处于纵向模式，希望设备保持直立，主屏幕按钮位于底部。        |
| **PortraitUpsideDown** | 应用程序处于纵向模式，但是上下颠倒，希望设备保持直立，主屏幕按钮位于顶部。 |
| **LandscapeLeft**      | 应用程序处于横向模式，希望设备保持直立，主屏幕按钮位于右侧。        |
| **LandscapeRight**     | 应用程序处于横向模式，希望设备保持直立，主屏幕按钮位于左侧。        |

要手动控制屏幕方向，请将 [Screen.orientation](/engine/6000.0/script-reference/unity-engine/screen/orientation.md) 设置为上述方向之一，或使用 [ScreenOrientation.AutoRotation](/engine/6000.0/script-reference/unity-engine/screen-orientation/auto-rotation.md)。启用自动旋转后，仍可根据具体情况禁用某个方向。

以下属性控制自动旋转：

* [Screen.autorotateToPortrait](/engine/6000.0/script-reference/unity-engine/screen/autorotate-to-portrait.md)
* [Screen.autorotateToPortraitUpsideDown](/engine/6000.0/script-reference/unity-engine/screen/autorotate-to-portrait-upside-down.md)
* [Screen.autorotateToLandscapeLeft](/engine/6000.0/script-reference/unity-engine/screen/autorotate-to-landscape-left.md)
* [Screen.autorotateToLandscapeRight](/engine/6000.0/script-reference/unity-engine/screen/autorotate-to-landscape-right.md)

应用程序的屏幕方向可能会根据用户设置的设备方向而有所不同，无论应用程序的默认方向设置如何。

下表显示了为应用程序设置的默认屏幕方向以及应用程序根据设备方向加载的实际方向。

|                         | **默认屏幕方向：Autorotate**                                                                                                                                                                                                                                                                                                                                           | **默认屏幕方向：Portrait**                                                                                                                                                                                                                                                                      | **默认屏幕方向：landscape**                                                                                                                                                                                                                                                                       |
| ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **设备方向：Autorotate**     | 应用程序屏幕加载为纵向，并可在纵向、纵向颠倒、横向向右和横向向左之间旋转。**注意**：在平板电脑上，应用程序屏幕根据设备方向加载为纵向或横向。                                                                                                                                                                                                                                                                                        | 应用程序屏幕加载为纵向，并可在纵向和纵向颠倒方向之间旋转。                                                                                                                                                                                                                                                            | 应用程序屏幕加载为与设备方向相同的方向。如果设备方向为纵向，应用程序屏幕将加载为纵向，并可旋转至横向。为横向时，屏幕只能在横向向右和横向向左之间旋转。**注意**：在平板电脑上，如果用户关闭设备自动旋转设置，然后重新打开应用程序，则应用程序屏幕方向保持不变。                                                                                                                                                          |
| **设备方向：Portrait lock**  | 应用程序屏幕将加载并始终锁定为纵向。**注意**：为纵向时，如果将纵向的 [ScreenOrientation.AutoRotation](/engine/6000.0/script-reference/unity-engine/screen-orientation/auto-rotation.md) 属性设置为 false，应用程序屏幕将保持为纵向，直到将设备旋转至横向。一旦变为横向，屏幕无法旋转回纵向。如果现在将横向的 [ScreenOrientation.AutoRotation](/engine/6000.0/script-reference/unity-engine/screen-orientation/auto-rotation.md) 属性设置为 false，则屏幕方向保持不变。 | 应用程序屏幕将加载并始终锁定为纵向。                                                                                                                                                                                                                                                                       | 即使将 portrait 选项设置为 false，应用程序屏幕也会加载并始终锁定为纵向。要允许屏幕旋转，请将所需的方向分配给 [Screen.orientation](/engine/6000.0/script-reference/unity-engine/screen-orientation.md) 属性。可以使用 [ScreenOrientation.AutoRotation](/engine/6000.0/script-reference/unity-engine/screen-orientation/auto-rotation.md) 启用自动旋转。 |
| **设备方向：Landscape lock** | 应用程序将加载并始终锁定为横向。                                                                                                                                                                                                                                                                                                                                                | 即使将任一选项设置为 false，应用程序也会加载为横向并始终锁定为横向向左或横向向右。要更改方向，请将所需的方向分配给 [Screen.orientation](/engine/6000.0/script-reference/unity-engine/screen-orientation.md) 属性。可以使用 [ScreenOrientation.AutoRotation](/engine/6000.0/script-reference/unity-engine/screen-orientation/auto-rotation.md) 启用自动旋转。 | 应用程序加载为横向，并根据设备方向始终锁定为横向向左或横向向右。                                                                                                                                                                                                                                                           |

## 多窗口模式##multi-window-mode

Android 的[多窗口模式](https://developer.android.com/guide/topics/large-screens/multi-window-support)支持 Unity 应用程序。用户可以调整将包含 Unity 应用程序的窗口的大小，因此最佳做法是使用户界面缩放到非标准宽高比和分辨率。
