- Home /
Unity 5 UI Fill Any Screen
Hello.
I have gone through the tutorials about UI and have been working with it since it came out but I can't seem to find a way for it to fill any screen resolution. How can I make it work for all aspect ratios?
Thank you.
Answer by DoTA_KAMIKADzE · Apr 24, 2015 at 03:21 PM
You should use "Scale with screen size" in your CanvasScaler componenet of your main UI canvas.
You might also want to check my few other answers related to your questions:
You can find few more by clicking on my nickname or here.
P.S. Also I'd recommend to use "Screen match mode" - Expand to work properly with different aspect ratios, but you can use match width/height as well depending on which resolutions you will support.
I already use the "Scale with Screen Size" and as I have noticed resizes everything within the canvas to the screen size. However it doesn't exactly have the result I want. I have everything anchored and even set a reference resolution to a 16:9 ratio. Here's a screenshot of how my canvas looks in two different situations:
Correct one:
Incorrect one:
I want my bg image (brown) to cover the whole screen and the notebook to stay in place. Do I have to do something else?
Anchor your notebook to center-right.
Set your background to stretch to the canvas size (aka each anchor on each corner of canvas).
Consider checking the links that I've provided in my answer.
Thank you it worked :) at least for expected aspect ratios.
Answer by InfernoZYB · Apr 24, 2015 at 03:24 PM
DoTA_KAMiKADze has got the right answer but I will post some images to help direct you:
First Select you're Canvas.
Then on the inspector it should look like this.
Change that to this.