Reputation: 3841
I created an empty 2D project - to try a tutorial from here
https://codeplanstudio.com/tutorials/block-adventure-game-tutorial/
(episode 2).
Added assets (graphics)
created Canvas
in the Canvas
a. canvas rendering mode Screen Space Camera
b. rendering camera set to Main Camera
c. Canvas scaler: scale with screen size, Reference resolution set x:1920 y:1080, match 0.5
added UI image to Canvas
in image
a. source image - an image from assets
b. set native size (native size is width:1080 height:1920)
When I look at the scene, the camera has the same dimensions with the canvas, but inverted: what should have been height is width and what should have been width is height.
What I was expecting was this (as seen in a video tutorial):
Any suggestions?
Upvotes: 1
Views: 127
Reputation: 90580
In your GameView on the top bar there is the Display X
dropdown and right next to it a resolution dropdown.
Per default it is usually Free Aspect
which means the camera resolution is whatever the resolution of the GameView
window is.
Open the dropdown and click on +
to create a new resolution option
Adjust it according to you needs e.g.
or using a dynamic resolution but fixed aspect ratio.
Now you can select it and no matter how the GameView
window is scaled now it always keeps this fixed resolution (or aspect ratio) for the camera.
Upvotes: 2