From 525ca49fbb21b33c4a2110c6ad8def0bade7bccd Mon Sep 17 00:00:00 2001 From: Nikos Kastellanos Date: Tue, 25 Feb 2025 05:24:08 +0200 Subject: [PATCH] switch (rotation) --- .../Game/.Android/AndroidCompatibility.cs | 48 ++++++++++++++----- .../.CardboardLegacy/AndroidCompatibility.cs | 48 ++++++++++++++----- .../Game/.Oculus/AndroidCompatibility.cs | 48 ++++++++++++++----- 3 files changed, 105 insertions(+), 39 deletions(-) diff --git a/Platforms/Game/.Android/AndroidCompatibility.cs b/Platforms/Game/.Android/AndroidCompatibility.cs index 913f44012eb..0f5e535e1b0 100644 --- a/Platforms/Game/.Android/AndroidCompatibility.cs +++ b/Platforms/Game/.Android/AndroidCompatibility.cs @@ -66,33 +66,55 @@ private Orientation GetDeviceNaturalOrientation(Activity activity) { case Orientation.Portrait: { - if (rotation == SurfaceOrientation.Rotation90 || rotation == SurfaceOrientation.Rotation270) - { - return Orientation.Landscape; - } - else + switch (rotation) { - return Orientation.Portrait; + case SurfaceOrientation.Rotation0: + case SurfaceOrientation.Rotation180: + return Orientation.Portrait; + + case SurfaceOrientation.Rotation90: + case SurfaceOrientation.Rotation270: + return Orientation.Landscape; + + default: + return Orientation.Portrait; } } break; case Orientation.Landscape: { - if (rotation == SurfaceOrientation.Rotation0 || rotation == SurfaceOrientation.Rotation180) - { - return Orientation.Landscape; - } - else + switch (rotation) { - return Orientation.Portrait; + case SurfaceOrientation.Rotation0: + case SurfaceOrientation.Rotation180: + return Orientation.Landscape; + + case SurfaceOrientation.Rotation90: + case SurfaceOrientation.Rotation270: + return Orientation.Portrait; + + default: + return Orientation.Portrait; } } break; default: { - return Orientation.Portrait; + switch (rotation) + { + case SurfaceOrientation.Rotation0: + case SurfaceOrientation.Rotation180: + return Orientation.Portrait; + + case SurfaceOrientation.Rotation90: + case SurfaceOrientation.Rotation270: + return Orientation.Portrait; + + default: + return Orientation.Portrait; + } } break; } diff --git a/Platforms/Game/.CardboardLegacy/AndroidCompatibility.cs b/Platforms/Game/.CardboardLegacy/AndroidCompatibility.cs index 3db2f830847..6d58d8a1661 100644 --- a/Platforms/Game/.CardboardLegacy/AndroidCompatibility.cs +++ b/Platforms/Game/.CardboardLegacy/AndroidCompatibility.cs @@ -66,33 +66,55 @@ private Orientation GetDeviceNaturalOrientation(Activity activity) { case Orientation.Portrait: { - if (rotation == SurfaceOrientation.Rotation90 || rotation == SurfaceOrientation.Rotation270) - { - return Orientation.Landscape; - } - else + switch (rotation) { - return Orientation.Portrait; + case SurfaceOrientation.Rotation0: + case SurfaceOrientation.Rotation180: + return Orientation.Portrait; + + case SurfaceOrientation.Rotation90: + case SurfaceOrientation.Rotation270: + return Orientation.Landscape; + + default: + return Orientation.Portrait; } } break; case Orientation.Landscape: { - if (rotation == SurfaceOrientation.Rotation0 || rotation == SurfaceOrientation.Rotation180) - { - return Orientation.Landscape; - } - else + switch (rotation) { - return Orientation.Portrait; + case SurfaceOrientation.Rotation0: + case SurfaceOrientation.Rotation180: + return Orientation.Landscape; + + case SurfaceOrientation.Rotation90: + case SurfaceOrientation.Rotation270: + return Orientation.Portrait; + + default: + return Orientation.Portrait; } } break; default: { - return Orientation.Portrait; + switch (rotation) + { + case SurfaceOrientation.Rotation0: + case SurfaceOrientation.Rotation180: + return Orientation.Portrait; + + case SurfaceOrientation.Rotation90: + case SurfaceOrientation.Rotation270: + return Orientation.Portrait; + + default: + return Orientation.Portrait; + } } break; } diff --git a/Platforms/Game/.Oculus/AndroidCompatibility.cs b/Platforms/Game/.Oculus/AndroidCompatibility.cs index 7c3859ea5c1..8dab5b0791c 100644 --- a/Platforms/Game/.Oculus/AndroidCompatibility.cs +++ b/Platforms/Game/.Oculus/AndroidCompatibility.cs @@ -66,33 +66,55 @@ private Orientation GetDeviceNaturalOrientation(Activity activity) { case Orientation.Portrait: { - if (rotation == SurfaceOrientation.Rotation90 || rotation == SurfaceOrientation.Rotation270) - { - return Orientation.Landscape; - } - else + switch (rotation) { - return Orientation.Portrait; + case SurfaceOrientation.Rotation0: + case SurfaceOrientation.Rotation180: + return Orientation.Portrait; + + case SurfaceOrientation.Rotation90: + case SurfaceOrientation.Rotation270: + return Orientation.Landscape; + + default: + return Orientation.Portrait; } } break; case Orientation.Landscape: { - if (rotation == SurfaceOrientation.Rotation0 || rotation == SurfaceOrientation.Rotation180) - { - return Orientation.Landscape; - } - else + switch (rotation) { - return Orientation.Portrait; + case SurfaceOrientation.Rotation0: + case SurfaceOrientation.Rotation180: + return Orientation.Landscape; + + case SurfaceOrientation.Rotation90: + case SurfaceOrientation.Rotation270: + return Orientation.Portrait; + + default: + return Orientation.Portrait; } } break; default: { - return Orientation.Portrait; + switch (rotation) + { + case SurfaceOrientation.Rotation0: + case SurfaceOrientation.Rotation180: + return Orientation.Portrait; + + case SurfaceOrientation.Rotation90: + case SurfaceOrientation.Rotation270: + return Orientation.Portrait; + + default: + return Orientation.Portrait; + } } break; }