- Home /
Screen.SetResolution causes screen to turn black (and other problems). Am I doing it right ?
In my game, I want players to be able to modify their resolution in runtime in a settings menu. For testing purposes, my code was like this (i've also tested other resolutions): if(Input.GetKeyDown(KeyCode.Alpha1)) Screen.SetResolution(800, 600, true); if(Input.GetKeyDown(KeyCode.Alpha2)) Screen.SetResolution(800, 600, false); if(Input.GetKeyDown(KeyCode.Alpha3)) Screen.SetResolution(1920, 1080, true); if(Input.GetKeyDown(KeyCode.Alpha4)) Screen.SetResolution(1920, 1080, false);
When I execute the function Screen.SetResolution(x, y, fullscreen), I get all sorts of scaling bugs.
My normal menu (4 arrows to go to different menu sections):..................................................... ....... ^....................................................................................................................................................... .... < o >................................................................................................................................................. ........v..................................................... 1-When i go from a small res (ex: 800 x 600) to a big one (ex: 1920 x 1080), the game screen goes to a 1080p size, but the game rendering gets HUGE (and out-of-screen). (we can see here only the top-left part of the game menu. The problem is not only the UI, the whole scene)
2-When I go from a big res (ex: 1920x1080) to a small one (ex: 800x600), the whole screen goes black (nothing is rendered).
3-I've tried to in and out of full screen, but it doesn't help (it even does other weird problems, like rendering the game at the right scale, but a third of the screen on the right) (I can't show you I can't put more than 2 attachments -.-)
IMPORTANT NOTE !!! If I enable the Re-sizable Window option and re-size the window, the screen adjusts perfectly. If the screen went black (case 2), it goes back to normal. If the rendering was to big (case 1), it goes back to normal.
Am I the only one with this problem ? I haven't found anything alike on the forum, unfortunately.
Answer by brandonkuka · Sep 29, 2015 at 06:08 PM
You are not alone. Unity closed out the bug (http://issuetracker.unity3d.com/issues/dx11-full-screen-with-low-resolutions-renders-incorrectly) but the issue is still present in 5.2.1.
More info: http://forum.unity3d.com/threads/5-2-canvas-stops-rendering-in-windows-standalone-in-d3d9.355944/
I have not because it looks like others already have. Reading through this thread (http://forum.unity3d.com/threads/why-does-the-fullscreen-bug-have-no-priority.346839/#post-2308331) there are mixed results regarding the fix that was patched in 5.2.1p1. I have not yet tried the p1 patched version, so I will look at that before reporting a new bug.
@msfredb7 - It looks like 5.2.1p1 patch (available here: http://unity3d.com/unity/qa/patch-releases) fixes the issue for us.
Cheers!