This is what I was using on the previous game I released. No idea whether it was “correct” or not, but it worked. I attached this to its own GameObject I think.
function Awake() {
DontDestroyOnLoad(this);
}
function Start() {
iPhoneKeyboard.autorotateToPortrait = true;
iPhoneKeyboard.autorotateToPortraitUpsideDown = true;
iPhoneKeyboard.autorotateToLandscapeRight = false;
iPhoneKeyboard.autorotateToLandscapeLeft = false;
}
function Update() {
if (Input.deviceOrientation == DeviceOrientation.Portrait)
iPhoneSettings.screenOrientation = iPhoneScreenOrientation.Portrait;
if (Input.deviceOrientation == DeviceOrientation.PortraitUpsideDown)
iPhoneSettings.screenOrientation = iPhoneScreenOrientation.PortraitUpsideDown;
}
If you get Unity 3.4, it comes with built in orientation. I removed all of my orientation scripts from my game and switched to Unity’s, it works very well. The option is in “player settings”. I have it set to Landscape only.