Search Issue Tracker

Fixed in 2021.1.X

Votes

1

Found in

2018.4

2020.1.4f1

2020.2

Issue ID

1283211

Regression

No

[WebGL][Android] Screen.orientation doesn't update on Android WebGL

WebGL

-

Reproduction steps:
1. Import the attached custom Package "screenorientationbug.unitypackage"
2. In the Project window under "Assets/Scenes" open "SampleScene.unity" and switch to WebGL Platform
3. Build for WebGL
4. Create a server using this "python -m http.server" command in the Command Prompt
5. Navigate to the built WebGL page on your Android device using your IPV4 address
6. Rotate the device

Expected result: Screen.orientation updates on Android WebGL
Actual result: Screen.orientation doesn't update on Android WebGL

Reproduced on these devices:
N/A, Samsung Galaxy S9 (SM-G960F), Android 8.0.0, CPU: Exynos 9 Series 9810, GPU: Mali-G72
N/A, Lge LG V50 ThinQ (LM-V500N), Android 10, CPU: Snapdragon 855 SM8150, GPU: Adreno (TM) 640
VLNQA00316, Samsung Galaxy Note10 (SM-N970F), Android 9, CPU: Exynos 9 Series 9825, GPU: Mali-G76

Reproduces on: 2018.4.28f1, 2019.4.12f1, 2020.1.8f1, 2020.2.0b7

  1. Resolution Note (fix version 2021.1):

    Fixed in 2021.1.0a3, backported to 2020.2, 2020.1 and 2019.4

Comments (3)

  1. Marks4

    Jun 02, 2022 13:55

  2. Hypertectonic

    Jun 16, 2021 01:26

    Why has this not been backported to 2020.3 but it has for 2020.2???
    What kind of long term support is that?

  3. Marks4

    Oct 12, 2020 16:59

    Here's a possible solution:
    var ori = (screen.orientation || {}).type || screen.mozOrientation || screen.msOrientation;
    if (!ori)//safari doesn't support it, resort to window.orientation
    ori = window.orientation === 0 ? "portrait-primary" : window.orientation === 180 ? "portrait-secondary" : window.orientation === 90 ? "landscape-primary" : "landscape-secondary";
    csharpscreenorientation = ori === "portrait-primary" ? 0 : ori === "portrait-secondary" ? 1 : ori === "landscape-primary" ? 2 : 3;

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.