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.