In my PlayerSettings I have the Default Screen Width set to 1280 and the Default Screen height set to 720. When I build the project the player launches in 1920x1080 and sets the width/height registry value to 1920x1080.
This was working all fine and dandy before updating to Unity 2017.2 (wow!).
It’s also worth nothing that my builds are also creating a 22MB ‘UnityPlayer.dll’ file on my Desktop which was not happening before updating to 2017.2 and I’m thinking this may have something to do with it.
The build/player stores the last used screen size in the Windows Registry and reads/restores it when the game starts. Once these values are written to the Windows Registry, “Default Screen Width/Height” have no effect anymore, because Unity reads it from the Registry instead.
To test modified Default Screen settings, it seems you need to remove the Windows Registry key before starting the game. That is at least the only workaround I found to make that work.
These keys are located under: Computer\HKEY_CURRENT_USER\Software\<Company Name>\<Product Name>\
Where <Company Name> and <Product Name> must be replaced with whatever you entered for those in the PlayerSettings.
Thanks for the tip. The problem is still present in 2019.1.0f2.
I didn’t delete the values you mentioned, I just modified the resolutions Height and Width with the correct values and my game displays at it should now.
This is kind of by design. You want the game to remember the last resolution it was run in. The player setting only specifies the default resolution - the resolution the game will start in. When you play any game, you usually want to adjust that resolution to either match your monitor resolution or reduce it if your GPU is weak. It would suck if you had to do it every time you started the game on your PC.
You’re right, I want my game to play full screen 600 x 900 like I built if, not full screen native resolution. Right now it doesn’t because the last resolution stored is 1920 x 1080 and setting the new resolution 900 x 600 is not recorded. If you find this normal, okay, I guess I’ll have to do with it.
You can always change the resolution to the one you want at startup in your code if you wish. However keep in mind that forcing a specific resolution will make your game look really badly on monitors with a different aspect ratio.
Edit: I just tried it in a game that doesn’t require pillarboxes just to see how it works and it does work very well. No need to modify the resolution in the Player settings. New aspect ratio 1:1.
Well, as I said, that player setting denotes the default resolution. It’s not “this is the resolution the game must run in” setting.
While the editor could modify the registry for your current PC, it falls apart as soon as you copy your game to another machine.
It does, but what kind of gamer wants his monitor space unused? Imagine you force 4:3 aspect ratio. People with ultra wide monitors will have over 40% of their monitor real estate rendered useless.
If you need this to test your local builds, just implement a PostProcessBuild step where you delete the registry keys. The next time you start your game, it will use the defaults.