Search Unity

How to know the Screen Orientation on start

Discussion in 'Scripting' started by DominoOne, Oct 7, 2015.

  1. DominoOne

    DominoOne

    Joined:
    Apr 22, 2010
    Posts:
    433
    Hello,

    We ran into this weird situation, so maybe someone can help.

    We need to know the Screen Orientation (landscape left, landscape right, portrait or portrait upside down) when the game starts. The problem is that we allow both landscape left and landscape right, so before the screen changes orientation, Screen.orientation reports AutoRotation (whenever the orientation changes, it starts reporting the specific orientation, but we need to know it BEFORE the orientation changes). Input.deviceOrientation also doesn't fully help, because it has FaceUp, FaceDown, etc., so if a device is lying on a table, we can't know what the screen orientation actually is.

    So, does anyone know a way in Unity (without using native plugins) to know for sure what Screen Orientation is before any orientation changes happen?
     
  2. Ramcat

    Ramcat

    Joined:
    Aug 16, 2014
    Posts:
    95
    Yes, Necro. But a well stated problem I'm also running into. Does anyone have the solution?

    BTW, I tried Screen.orientation with no luck either. It reports "Portrait" even when starting in landscape.