Hello everyone! Thank you for reading my question!
I have a sprite that I want to scale so that its width is the same as the screen width. Nothing I have tried has worked like this.
I’ve tried changing the Draw Mode to Sliced and altering the width to 1080 (the width of my canvas) but the sprite sometimes is too wide or too narrow (depending on the device)
How can I solve this?
If you’re talking UI, you need to set the anchors properly. See below.
If you’re talking raw sprite, then the camera height (ortho) can give you the proper width by the ratio of Screen.width vs Screen.height, just do it in a little script if it must change, or make it worst-case for 1920x1080 or whatever you want.
Here are the official docs on how to make your UI handle various resolutions and aspect ratios cleanly:
Here are some notes on UI Anchoring, Scaling, CanvasScaler, etc:
Thank you @Kurt-Dekker for your response. I figured out the solution to my problem. I wasn’t setting the right orthographic size for my camera. Now I set the correct sprite size under Draw Mode: Sliced and it works like a charm
1 Like