0
votes

I am working on a unity UI project. I had multiple scenes. my scenes are on portrait mode except the last scene. last scene is landscape mode. for the last scene at start method I set Screen Orientation to LandscapeLeft and set the canvas scaler referance resolution 800*600. I work with 480*800 screen and screen match mode is "match width or height" and match is width so the canvas SHOULD scale up to 800*480 on landscape mode. because of the width must match the height is gonna be the max value for screen

but when I run unity the screen doesnt change to landscape for last scene and the canvas sizes are 800*1333 when I select the landscape resolution 800*480 the canvas sizes change to 800*480 but since the script cant wait for me to select the resolution my script thinks the canvas sizes are 800*480

void Start()
{
   Screen.orientation = ScreenOrientation.LandscapeLeft;
   Debug.Log(Screen.width+" - "+Screen.height);//output: 480-800
   Debug.Log(canvas.GetComponent<RectTransform>().rect.width + " - " + canvas.GetComponent<RectTransform>().rect.height);//output: 800-1333
}

enter image description here

I set to landscape at start but game comes like this I expected to change to this:

enter image description here

am I doing wrong when I try to change the orientation ? why doesnt the game panel change to landscape How can I get the landscape canvas sizes?

1
Post pictures and codevasmos
@vasmos editted.eomer

1 Answers

0
votes

Changing the orientation of your device does not rotate or scale canvases.

The match width or height will just scale the canvas until it hits a side of the screen or the top/bottom of the screen if its played using a device not matching the original resolution.

Solution:

Change canvas to world space and rotate/scale it when you change the device orientation

Edit:

In your canvas component under 'Render Mode' select world space