- Home /
SetResolution in full screen is a nightmare (Standalone Windows)
Hey
I wanted to allow the user to change the resolution of my standalone WIndows application in game . It does seems quite simple, but in fact resolution change works extremely badly in fullscreen mode. Here are the different solutions I tried :
D3D11 Fullscreen mode : Fullscreen Window => Changing resolution by using Screen.SetResolution resolution works... But if the resolution is not the maximum resolution handled by the screen then there are black strips on the borders instead of upscaling to the screensize. Moreover the UI detects events at bad positions. Also, performances are worse than in Exclusive mode.
D3D11 Fullscreen mode : Exclusive => At least the game run in a true full screen mode. Yes it does crash if you use Alt tab but I don't find this behavior really dramatic. BUT changing resolution often makes the game crash. And I found no way to define a start resolution by script... The game launch at its default resolution and then, even putting it in awake, the SetResolution function is called and eventually makes the game crash. By crash I mean a black screen. I tried to switch from windowed mode to fullscreen when changing the resolution but it doesn't keep the game from crashing.
OpenGLCore instead of direct3D : The game crashes deadly ("ERROR: Error while initializing dbghelp.dll, GetLastError: 'L’opération a réussi.' (Address: 00000000)") immediately in full screen for a lot of different resolution which are supposed to be supported...
So the only way I see it working is by keeping the default launcher to allow the user to choose the resolution... Did I miss something or Unity really doesn't handle well at all resolution changing in full screen mode on Windows ? This behavior happened in both Windows 10 and Windows 8.1. I didn't try D3D9 but I really don't want to use it.
Sincerely, Léo.
[UPDATE] It seems to be possible to define the game resolution by sending command line arguments as it's described here : http://docs.unity3d.com/Manual/CommandLineArguments.html I think I'm going to create a custom launcher doing that. Or maybe make my game restart to apply a resolution change.
Are you using Unity 5.2? When I upgraded to it the problem appeared, it worked well in earlier versions though. People have already filed bug reports as far as i know.
Yes I'm using Unity 5.2. Thank you for your answer, let's wait for a bug correction in the next version...
I hope they get this fixed soon. It has already caused lots of problems for many people.
Answer by Triss211 · Oct 03, 2015 at 11:40 AM
So apparently this is a Unity 5.2 bug... Anyway I worked around the problem by restarting the application to change the resolution with this coroutine I wrote :
public IEnumerator coroutResolution()
{
//get the toggle full screen value
m_newFullScreen = m_toggleFullScreen.isOn ? 1 : 0;
//Go to windowed mode because if you restart the game from full screen in exclusive mode it sometimes keep the same aspect ratio..
// Set to the new resolution because it will kept this resolution when restarting
Screen.SetResolution(m_resolutions[m_ddResol.value].width, m_resolutions[m_ddResol.value].height, false);
yield return new WaitForEndOfFrame();
//We get the executable location
string[] s = System.Reflection.Assembly.GetExecutingAssembly().Location.Split('\\');
StringBuilder location = new StringBuilder();
for (int i = 0; i < s.Length - 3; i++)
{
location.Append(s[i] + '\\');
}
location.Append(m_exeName);
string exe = location.ToString();
//Start the new process with only the fullscreen parameter, height and width being kept if the resolution launcher is disable
System.Diagnostics.ProcessStartInfo start = new System.Diagnostics.ProcessStartInfo();
start.Arguments = "-screen-fullscreen " + m_newFullScreen;
start.FileName = exe;
System.Diagnostics.Process.Start(start);
//Quit the app
Application.Quit();
//Update the player pref because for some reason Screen.currentResolution doesn't work really well for me
PlayerPrefs.SetInt("resolution", m_ddResol.value);
}
Your answer
Follow this Question
Related Questions
Comodo Firewall hangs Unity in fullscreen standalone mode 0 Answers
Borderless window in standalone player 5 Answers
Standalone player in windows open fullscreen, but player settings says windowed 1 Answer
Unity does not change the size of the window 0 Answers
Mac Retina Support Standalone OSX 1 Answer