Version: Unity 6.3 LTS (6000.3)
LanguageEnglish
  • C#

Screen.currentSwapChainPreTransform

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public static Rendering.SwapchainPreTransform currentSwapChainPreTransform;

Description

The rotation that Unity applies during rendering to match the native orientation of the device's display panel.

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:

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. Only Android with the Vulkan graphics API supports pre-rotation.
  • Apply display rotation during rendering is disabled in the Android Player settings. To check this setting from an Editor script, use PlayerSettings.vulkanEnablePreTransform.
  • 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 UNITY_DISPLAY_ORIENTATION_PRETRANSFORM has the matching value.

Unity 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.