Orientation always in Portrait?

Hi there

I have a dummy project with just one object and script with this code :-

using UnityEngine;
using System.Collections;

public class CheckOrient : MonoBehaviour {

	// Use this for initialization
	void Start () {
		Screen.orientation = ScreenOrientation.Landscape;
	}
	
	// Update is called once per frame
	void Update () {
		Screen.orientation = ScreenOrientation.Landscape;
		Debug.Log ("Orientation : " + Screen.orientation);
	}
}

However , its strange that on the Simulator it always prints the orientation as “Portrait” .
We even forced it in the Package.appxmanifest to prefer Landscape and still it keeps
printing the orientation as “Portrait”

Any ideas why this will happen ? Its strange because its all working fine on WPhone.

Regards
Shashank

Which version of Unity do you use?
I remmember fixing supported orientations and forcing orientation. I think forcing orientation should work fine in 4.3, but autorotation to particular orientations were only added in alpha version of the next release.

Hi…I’m using Unity 4.3.3f1 and running on the following : -

  • Winows 8.1 Enterprise 64-bit
  • VS Express 2013
  • XAML C# targeting SDK 8.1

Thanks
Shashank

Just looked, forcing orientation on start up and autorotation to specific rotations fixes are not in 4.3, so if you you’ll have to wait for the next release, I’m affraid, as new 4.3 releases, if any, are only for really critical issues.
For now, you can work around this issue by acessing WinRT API directly.

Thanks…we’ll look into it further…any ETAs for the next Unity release ?

Regards
Shashank

Just curious if this has been added in 4.3.4 ? I ask this because we have some file download permission restrictions in our
office, so I can download it if this update has orientation related fixes. Thanks.

Regards
Shashank

No, 4.3.4 contained only a hotfix for iOS.

aah ok…any headsup as to where I can look and fix it ? The game starts just fine in landscape but somewhere
in between in one of the scenes, the game requires us to play it in portrait and then everything screws up
because Input.deviceOrientation is not getting set correctly…the same code works perfectly in WPhone
though…

As I said before, you have to go behind Unity and use WinRT API to set/get orientation, that will work reliably.
Note, that Portrait orientation not always work. It doesn’t work on desktop. When you attach keyboard to tablet, it becomes desktop and portrait orientation can not be enforced.

Thanks, but the strange thing is that it defaults to Portrait instead of Landscape in a test project…aren’t tablets supposed to be
Landscape by default ? I was testing this on Simulator | x86 | Debug.

Don’t trust the Simulator when working with orientations, it doesn’t work as expected. You have to use real device

Thanks for the tip…I’ll check this out.