I have a 2D game set to 1080p pixel size (so each unit equals 1 pixel) and I have added a canvas to my scene. However the canvas fills only about 1/8th of the screen and is also not central either. All the canvas size and position settings are locked so I cant move it or resize it. The canvas itself does reflect the screen (ie if I put text in the top right corner it appears correctly) but the size makes it hard to judge where best to position the elements).
How do I get the canvas to fill my scene?
To set a standalone player to be full screen, go to Edit>Project Settings>Player and under the Resolution and Presentation heading, check Default is Full Screen . To change resolution to full-screen at run-time, you would just use [Screen. fullScreen][1] = true; .
In UGUI, you can set the Canvas to scale with screen size. For example, you can set the Reference Resolution to 1920 x 1080, and then place a button 200 x 200, and then resize the screen resolution to however you like and it will always keep the same exact scale ratio.
On your canvas, set the Canvas Scaler
component's Ui Scale Mode
to Scale with Screen Size
. Then you can define a Reference Resolution
of 1080p, i.e. 1920 x 1080.
EDIT: To see the canvas fit into the camera's size in the scene, change the Canvas
component's Render Mode
to Screen Space - Camera
, and drag the camera from the hierarchy to it.
(check this video)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With