- Home /
Difference between Screen.orientation - Input.deviceOrientation
As per my title suggest, what is difference between Screen.orientation and Input.deviceOrientation?
Answer by meat5000 · Apr 15, 2016 at 02:11 PM
deviceOrientation is 3D whereas Screen.orientation is always pointing at your face, so 2D.
deviceOrientation also includes Face Up, Face Down and Unknown as well as all the Screen.orientations portrait and landscape.
Also, Screen.orientation is handled by Unity but deviceOrientation is reported by the OS.
Seriously though, you can read both pages from the docs and see this for yourself!
Also, dont forget that the Device can have a different screen orientation independently of the way the device is pointing. FaceUp or FaceDown it can still be in portrait or landscape.
Answer by Owen-Reynolds · Apr 15, 2016 at 04:28 PM
Input.deviceOrientation is telling you the actual way the device is being held. It changes as they tip the device, but it won't spin around your game. It's just reporting, in case you want to do anything.
Screen.orientation is a variable, which you can use to spin the screen. If you set autoRotate, it will somewhat track deviceOrientation, which might be the confusing part. Simple code will read deviceOrientation, and use it to set screen.orientation.
@Owen Reynolds, what is your suggestion about, if I want to make game that runs in both orientation. which one I need to use from above 2?
deviceOrientation is Read Only, so it has to be Screen.orientation. On top of that diagonals with deviceOrientation come out as $$anonymous$$, which is pretty damn useless.
This is all useless really as you ultimately specify this stuff in the Player Settings.