- Home /
webplayer fullscreen aspect ratio wrong
Hi,
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?
thanks,
Jean
Answer by Jesse Anders · Oct 15, 2010 at 03:00 PM
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).
Thanks Jesse for your insight, much appreciated, Will get back on this question if I have any more infos to add or a proper answer myself...
Answer by Gillissie · Apr 20, 2011 at 05:46 AM
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);
}
}
This doesn't work. I made a empty game object called resolution and dragged this script onto it. I then put the prefab in all of my scenes but when I right-click the game and "go fullscreen" it hasn't changed anything. Any help guys?
Answer by yosh · Dec 02, 2010 at 02:02 PM
Hi, are there any new ideas about switching to fullscreen and setting an aspect ratio? I have the same problem.. would be great! Thanks
Is the solution above not working? it works fine on that particular project: http://www.fabrejean.net/projects/excavator or do you have another problem?
@$$anonymous$$ Fabre What you mean "the solution" ? And what have you done in excavator ? it works perfect !
Answer by FWCorey · Oct 03, 2012 at 01:59 AM
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.