currentSwapChainPreTransform
The rotation that Unity applies during rendering to match the native orientation of the device's display panel.
読み終わるまでの所要時間 2 分最終更新 21時間前
Definition
- Type: Property
- Namespace: UnityEngine
- Assembly: UnityEngine.CoreModule
public static SwapchainPreTransform currentSwapChainPreTransform { get; }
Remarks
When pre-rotation is active, Unity renders each frame to the backbuffer already rotated to the native orientation of the display panel, so the operating system doesn't need to rotate the image again before it displays it. Use this property to find out which rotation Unity applies in the current frame. For more information, refer to Framebuffer orientation.
This value isn't a screen orientation or a device orientation. It describes the rotation of the app's window relative to the native orientation of the display panel, which differs between devices:
- Most phones have a portrait native panel. A landscape app on a phone reports SwapchainPreTransform.Rotate90 or SwapchainPreTransform.Rotate270.
- Most tablets, foldables, and Chromebooks have a landscape native panel. A landscape app on these devices reports SwapchainPreTransform.Identity, and a portrait app reports SwapchainPreTransform.Rotate90 or SwapchainPreTransform.Rotate270.
- The value follows the rotation of the app's window, not the physical device. If the screen orientation is locked and the user turns the device, Input.deviceOrientation changes but this value doesn't.
To find out whether the app is in portrait or landscape, use Screen.orientation. To read the physical orientation of the device, use Input.deviceOrientation.
The value is SwapchainPreTransform.Identity in the following cases, because Unity doesn't apply pre-rotation:
- The platform or graphics API doesn't support pre-rotation, and SystemInfo.supportsSwapChainPreTransform is . Only Android with the Vulkan graphics API supports pre-rotation.
false - Apply display rotation during rendering is disabled in the Android Player settings. To check this setting from an Editor script, use PlayerSettings.vulkanEnablePreTransform.
- QualitySettings.disableSwapChainPreTransform is .
true - The app has no visible window, for example when it's in the background.
- The app runs in the Unity Editor, including the Device Simulator.
Unity applies pre-rotation only when it renders to the backbuffer, not when it renders to a RenderTexture. When Unity renders to the backbuffer, the shader constant has the matching value.
UNITY_DISPLAY_ORIENTATION_PRETRANSFORMUnity updates this value when it recreates the swapchain after the display rotates. During a rotation, this value can briefly differ from Screen.orientation.
Additional Resources: SwapchainPreTransform, SystemInfo.supportsSwapChainPreTransform, QualitySettings.disableSwapChainPreTransform.