Can Unity automatically rotate screen when I for example turn device in my hands from "Portrait" position to "Portrait Upside Down" position? Is it possible in Unity at all?
Open player settings (Edit → Project Settings → Player) and open the “Resolution and Presentation” section.
Select “Auto Rotation” for the “Default Orientation” and select the orientations you would like to support.
Here, use this code. It will throw some warnings in Unity because there are some newer methods, but they all still work. I just used this in a recent app.
`if(/Vector3.Dot(Input.acceleration.normalized, new Vector3(0,-1,0)) > 0.8/Input.deviceOrientation == DeviceOrientation.Portrait) { iPhoneSettings.screenOrientation = iPhoneScreenOrientation.Portrait; } else if(/Vector3.Dot(Input.acceleration.normalized, new Vector3(1,0,0)) > 0.8/Input.deviceOrientation == DeviceOrientation.LandscapeRight) { iPhoneSettings.screenOrientation = iPhoneScreenOrientation.LandscapeRight; } else if(/Vector3.Dot(Input.acceleration.normalized, new Vector3(-1,0,0)) > 0.8/ Input.deviceOrientation == DeviceOrientation.LandscapeLeft) { iPhoneSettings.screenOrientation = iPhoneScreenOrientation.LandscapeLeft; } else if(/Vector3.Dot(Input.acceleration.normalized, new Vector3(0,1,0)) > 0.8/Input.deviceOrientation == DeviceOrientation.PortraitUpsideDown) { iPhoneSettings.screenOrientation = iPhoneScreenOrientation.PortraitUpsideDown; }`