We solve some specific trouble with fullscreen. Our request is to lunch application to fullscreen at current system resolution. For exammple my HP has 1920x1200px maximum native resolution and ma fujitsu has 1680x1050. It possible detect actual screen resolution and set it to fullscreen for each computers?
asked Mar 02 '11 at 09:14 AM
Not directly with Unity's API. You could use an external library for that that will tell you current desktop's resolution, but you'd have to find it on your particular platform which might prove difficult (and definitely annoying). Plus you'd have to find a specific solution for each platform you're targeting (for instance, a solution specific for Windows, and another one for OSX).
However Unity can give you a list of all the resolutions supported by the user's monitor screen:
This array contains all those resolutions. If you pick the last one in the array, it's the largest resolution supported, and is often the native resolution of the screen. So it's your best bet.
There are two things you should be careful about with this though. One is not so bad, the other one much much worse:
1) The highest value might not be the monitor's native resolution, some monitors accept higher resolution (mine for instance is a native 1680*1050 but accepts and displays up to 1920*1200), and the array will reflect that.
2) Even if a value is in the array of resolutions, and even if Unity promises that the resolutions returned in this array are all supported by the monitor, well, I'm afraid this is unreliable. We had users who would pick an unsupported resolution and ending up being stuck with a black screen. So make sure you add some sort of timer after picking a new resolution where the user must agree to it, turning back to the previous working resolution if he doesn't.
You can achieve the functionality you need with Unity's API, by starting the application in windowed mode and using Screen.currentResolution to fetch the desktop resolution. Then switch to fullscreen mode at the resolution of the desktop.
Our title also urgently needs this functionality, and it is baffling that this is not an option in the Player Settings -> Resolution and Presentation dialog. I'm using 3.4.2 pro and have not looked at the 3.5 beta to see if things are better there.
The good news is that I have found a workaround for PC:
Go into the Player Settings -> Resolution Presentation and set the "Default Screen Width/Height" to obscenely large number (I'm using 32000).
Then when launched, standalone app apparently will realize it is unable able to achieve this resolution, and will just keep the resolution untouched - which is exactly what we want, and will still go fullscreen.
Unfortunately the logic seems completely different for the mac and doesn't work there. Doing the same thing on the mac causes it to jump to the highest available resolution, which is not desired. On both platforms, setting it to small values (including 0 and negative values), causes the resolution to be hard set to 640x480.
A few more notes: on the PC the values seem to be stored in the registry under
but note that these values appear to be stomped on every launch by the values hard coded in the Player Settings so I don't think they are relevant. On the mac, the same settings are stored in
We are going to continue to try to find workarounds for the mac. If anyone else has solutions for this issue, we'd love to hear it!