Le changement de résolution en mode full screen pour Unity 5.2 est très capricieux sur Windows, je vous propose donc cette coroutine qui permet de redémarrer le jeu tout en changeant la résolution et le mode fenêtré/plein écran. Cela fonctionne avec le player en mode D3D11 fullscreen exclusive et le launcher désactivé.
Pour plus de détail sur ma démarche et en quoi le changement de résolution marche mal je vous invite à regarder ma question sur Unity answers :
http://answers.unity3d.com/questions/10 ... nda-1.html
Code : Tout sélectionner
/// <summary>
/// Redémarre et change la résolution
/// </summary>
/// <param name="execName">Nom de l'executable (ex : monjeu.exe )</param>
/// <param name="width">largeur</param>
/// <param name="height">hauteur</param>
/// <param name="fullscreen">plein écran</param>
public IEnumerator coroutResolution(string execName,int width, int height, bool fullscreen)
{
//Go to Windows 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(width,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(execName);
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 " + fullscreen;
start.FileName = exe;
System.Diagnostics.Process.Start(start);
//Quit the app
Application.Quit();
}