# How to stretch screen image to fit higher res monitors set to lower resolutions with Unity?

Using Screen.SetResolution(width, height, windowMode); , how might I stretch the image to match the monitor size? I've noticed this problem occurs both with this line of code and also the default unity configuration launcher.

No body seems to discuss this issue which is odd to me.

• Well, viewports stretches automatically to fill screen, without any extra coding. I can't get the point of your question. – S. Tarık Çetin Dec 11 '15 at 14:54
• is the image a UI component ? – Uri Popov May 10 '16 at 9:31

If I was using this as a background image for instance. I would use a larger resolution so it would scale down on devices with lower res rather than up and pixelate.

• I dont mind to up and pixilate if the user wants to use lower resolution on higher res monitor. I'd just like to stretch the image to fit the screen. – Euthyphro Sep 12 '15 at 1:46
• Have you tried to refresh the screen after setting the res? or force the image to Screen.height Screen.width? If you force a resolution smaller than what the device is set to the area that your arrows are in the example image will be very undesirable. Is this image in a UI canvas and still not stretching properly? – Justin Markwell Sep 12 '15 at 14:05

You have to set Image anchoring and require to mess with canvas Scalar.

And you have to remember that

UI elements are by default anchored to the center of the parent rectangle. This means that they keep a constant offset from the center.

If the resolution is changed to a landscape aspect ratio with this setup, the buttons may not even be inside the rectangle of the screen anymore.

As it is a long topic, i will recommend you the unity official tutorial Designing UI for Multiple Resolutions

• I don't think this answers the question. The user here has reduced the resolution of the screen, so what you're seeing in the image is not just a sprite anchored to the top of a canvas. That's the Unity splash screen rendering to the "full" 800x600 resolution, but instead of stretching this to fill the actual display pixels, the graphics driver or OS is letterboxing it instead. I've seen this happen with laptop displays especially. – DMGregory May 2 '17 at 12:15
• Maybe we should ask for more details about the questions.user didn't mention it is splash screen. mostly these kind of problem anchors due to wrong anchoring, according to my experience. – Muhammad Faizan Khan May 3 '17 at 4:40
• The question literally shows a picture of the standard Unity splash screen circa 2015 when the question was asked. The user specifically asks about changing the rendered screen resolution using SetResolution or by selecting a lower resolution in the Unity launcher, and ensuring the result fits the extents of the monitor. At no point do they mention UI canvases. You're absolutely right that anchoring problems are common, but this is not asking about that. – DMGregory May 3 '17 at 9:38