x


Standalone application fullscreen

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?

more ▼

asked Mar 02 '11 at 09:14 AM

mirecek gravatar image

mirecek
3 3 3 4

(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

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:

Resolution[] Screen.resolutions

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.

more ▼

answered Mar 02 '11 at 09:50 AM

taoa gravatar image

taoa
1.6k 8 13 34

Please, have you more information about external library for Mac and Windows? Thanks for advice

Mar 03 '11 at 06:18 AM mirecek

Sorry, no. Google is your friend.

Mar 03 '11 at 10:19 AM taoa
(comments are locked)
10|3000 characters needed characters left

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.

example:

void Awake()
{
    Resolution res = Screen.currentResolution;
    Screen.SetResolution(res.width, res.height, true, res.refreshRate);
}
more ▼

answered Dec 01 '12 at 03:25 AM

Corscaria gravatar image

Corscaria
17 2

Are you sure? Because i just tried the same in my pc and it gave me the second lowest resolution that is supported by my monitor.

Mar 15 at 03:12 PM 3yanlis1bos
(comments are locked)
10|3000 characters needed characters left

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

HKEY_CURRENT_USER->Software->Title->ScreenManager Resolution

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 ~/Library/Preferences/unity.Title.plist - but these are not stomped and instead are used on each subsequent launch.

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!

more ▼

answered Jan 23 '12 at 10:18 PM

wemotom gravatar image

wemotom
31 1 1 1

You literally saved my life with the number 32.000. Thanks!

Mar 12 '12 at 07:15 PM kevinseligmann

@kevinseligmann is someone holding you at gunpoint for a fullscreen resolution? :p

Mar 12 '12 at 07:31 PM by0log1c

@BY0LOG1C Kind of hahaha. Let's say that without that number, my presentation today wouldn't have been possible, and who know what would have happened...

Mar 12 '12 at 08:59 PM kevinseligmann
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x381
x128
x85
x5

asked: Mar 02 '11 at 09:14 AM

Seen: 2684 times

Last Updated: Mar 15 at 03:12 PM