Screen.resolutions in windowed mode

Hi all,

When changing the resolution of a game in windowed mode, it will fail if the chosen resolution is higher than the available screen space.

The problem is that the available screen space includes the start bar and Screen.resolutions don’t take that into account.

Is there any way to retrieve accurate available resolutions in windowed mode on Windows 10?

Is this on standalone player or windows store? Any reason you don’t want to use fullscreen?

This is UWP.

I do use fullscreen, but any player can move the cursor to the top right of a UWP app and ‘restore’ the window, taking it out of fullscreen. It seems we have no control over this.

That’s correct, it’s impossible to enforce window size restrictions on UWP. I don’t think there is a good way to figure out the client area (the area excluding task bar, title bar and window borders) for the window on UWP (as far as I’m aware).

I’m still trying to figure out your scenario: if the user exits full screen, you can reenter it by passing true to the last parameter of Screen.SetResolution. Note that it may fail if you try to do it forcefully right after the player has exited fullcreen. The player can also always maximize the window manually with the maximize button on the title bar. In what case do you want to resize the window to highest size but still retain windowed mode?

So this is our video options screen:

When not in fullscreen, there’s no way of knowing which resolutions are supported, to populate the list.

I guess I could just disable the resolution option when in windowed mode.

1 Like

Disabling resolution option in windowed mode sounds like a good idea.

Here’s another idea if you don’t want to do that. You could use Screen.currentResolution to find the desktop resolution, and then just heuristically filter out bigger or equal resolutions.

The thing is, in windowed mode any resolution is supported that’s smaller than the desktop resolution. The Screen.resolutions list isn’t meaningful there. But it is handy when you need to come up with a list, as it reports the resolutions as supported by your monitor in fullscreen mode.

Thanks that did the trick :slight_smile: