Having a difficult time fixing the aspect ratio when user is going fullscreen using my webplayer built.
Any hints why aspect ratio is not respected and/or what can be done to make sure aspect ratio is right and pixels are not distorted when going fullscreen on a webplayer?
I don't have an answer per se, but since you haven't gotten any replies yet I'll go ahead and respond.
My understanding of the web player's behavior (which may be incorrect) is:
Fullscreen mode defaults to the default resolution for the standalone as specified in the 'Player' project settings.
If this resolution is not supported, the closest resolution is selected.
The selected resolution is then adjusted so that it's no greater than the desktop resolution.
I haven't done any testing on non-4:3 monitors yet, so I'm just speculating here, but it seems to me that in some cases this could result in selecting a resolution with an aspect ratio that's different than the screen's native aspect ratio. Is that the problem you're running into?
A suggestion I've seen made on the forums is to set the default width and height for the standalone to values that are higher than any modern hardware is likely to support. Assuming the process the web player uses to select a fullscreen resolution is as I described above, this would ensure that the desktop resolution was selected (which means if the desktop resolution has the right aspect ratio, your game will too).
It seems to me this could be the wrong choice in some situations though. Say the user has his or her desktop set at 1600x1200; some games might perform poorly at that resolution, and for them a lower resolution would be more appropriate.
So I don't know the answer, but having started working on the web player version of my current project, I've been wondering about this as well. I certainly don't want users switching to fullscreen and getting a stretched or distorted image (I'd rather not have a fullscreen option at all, although that wouldn't be ideal either).
Again though, I've only just started to look into this (I'm sure there are others here who could offer much better answers).
Easy, just set the full screen resolution to the desktop resolution.
`
function toggleFullScreen()
{
if (Screen.fullScreen)
{
// Set your windowed resolution to whatever you want here.
Screen.SetResolution(760,600,false);
}
else
{
// Switch to the desktop resolution in fullscreen mode.
Screen.SetResolution (Screen.currentResolution.width, Screen.currentResolution.height, true);
}
If performance at a particular resolution could be an issue, provide a game options menu with select-able resolutions from a List<> then save them to PlayerPrefs you can read them back when you switch to fullscreen.
If you are using PlayerPrefs I recommend setting your preference strings to static constants as well so you don’t have issues where you typoed a name.
Use Direct3D 9 instead of 11 => boom, it works! (at least for me)
And I have no glitches with D3D9, whereas with D3D11 my windows are a bit messed up once I leave fullscreen mode in my web player game.
It’s true though that the desktop resolution settings corresponds (roughly) to the web player fullscreen resolution setting, but only with D3D9.