Mobile Orientation

I couldn’t find an answer searching online, so I’ll ask here.

How can I get the game view in the editor to emulate what an actual phone will look like? When I change the aspect ratio of the camera to 9:16 from 16:9, it just cuts off either side so that the camera is actually viewing less. What I want it to do is act as if I’m rotating the camera so that it’s the same size, just a different orientation. How can I get that to work?

I have to increase the size of the camera by 1.77778 to get the size I want. Would I have to do the same thing for the actual mobile build?

You have to fix the screen for all views. Try the new Unity UI link text

or a third party plugin like NGUI

Just in case you don’t already do this you can set the aspect ratio of your game from the game view and even add your own:

39440-aspect.png

But if you just want to change values, which you probably will for all sorts of things you can check the Orientation like this:

if(Input.deviceOrientation == DeviceOrientation.LandscapeLeft || 
     Input.deviceOrientation == DeviceOrientation.LandscapeRight)
{
     // do landscape stuff here
}
else if if(Input.deviceOrientation == DeviceOrientation.Portrait || 
     Input.deviceOrientation == DeviceOrientation.PortraitUpsideDown)
{
    // do portrait studff here
}

Or you could simplify by checking is Screen.height > Screen.width and set a bool to set the mode yourself:

private bool AmIportrait;

if(Screen.height > Screen,width)
{
    AmIportrait = true;
}
else
{
    AmIprotrait = false;
}

if(AmIprotrait)
{
    // Do stuff here
}