Search Unity

Dynamically change resolution on startup [Windows desktop]

Discussion in 'Scripting' started by eco_bach, Feb 23, 2020.

  1. eco_bach

    eco_bach

    Joined:
    Jul 8, 2013
    Posts:
    1,601
    Building a windows desktop application and want to be able to dynamically change the application resolution on startup but nothing works.

    I'm using the 3rd override in this reference since after some googling one user suggests you must use ExclusiveMode to change resolution and it only works on windows
    https://docs.unity3d.com/ScriptReference/Screen.SetResolution.html

    Code (csharp):
    1.   public static void SetResolution(int width, int height, FullScreenMode fullscreenMode, int preferredRefreshRate = 0);
    But how do you supply FullScreenMode.ExclusiveFullScreen to the SetResolution function call?
    Whenever I try I get an error
    "FullScreenMode" not found in the current context.
    I need to somehow pass FullScreenMode.ExclusiveFullScreen as the 3rd argument

    https://docs.unity3d.com/ScriptReference/FullScreenMode.ExclusiveFullScreen.html