Search Unity

Screen.resolutions doesn't return full list in build

Discussion in 'Editor & General Support' started by _eternal, Mar 8, 2019.

  1. _eternal

    _eternal

    Joined:
    Nov 25, 2014
    Posts:
    304
    In Unity 2018.3.7, I noticed that Screen.resolutions stopped returning the full list of resolutions both in the editor and in the Windows build. The only result that I get is "2560 x 1440 @ 144Hz", which is the resolution of my primary monitor. Here's the relevant part of the code (the selectableResolutions part is to remove duplicates):

    Code (CSharp):
    1. Resolution[] resolutionsTemp = Screen.resolutions;
    2. Vector2 prevRes = Vector2.zero;
    3. string screenResolutions = "";
    4. string selectableResolutions = "";      
    5. for (int i = 0; i < resolutionsTemp.Length; i++)
    6. {
    7.      Vector2 resVec = new Vector2(resolutionsTemp[i].width, resolutionsTemp[i].height);
    8.      if (prevRes != resVec)
    9.      {
    10.          selectableResolutions += resolutionsTemp[i] + ", ";
    11.      }
    12.      prevRes = resVec;
    13.      screenResolutions += resolutionsTemp[i] + ", ";
    14. }
    15. print("All resolutions supported by monitor (retrieved via Screen.resolutions): \n" + screenResolutions);
    16. print("All resolutions selectable in the game: \n" + selectableResolutions);
    17. print("Total available resolutions: " + Screen.resolutions.Length);
    And in the build, this gives me:

    Code (CSharp):
    1. All resolutions supported by monitor (retrieved via Screen.resolutions):
    2. 2560 x 1440 @ 144Hz
    3. (Filename: C:\buildslave\unity\build\Runtime/Export/Debug.bindings.h Line: 45)
    4. All resolutions selectable in the game:
    5. 2560 x 1440 @ 144Hz
    6. (Filename: C:\buildslave\unity\build\Runtime/Export/Debug.bindings.h Line: 45)
    7. Total available resolutions: 1
    8. (Filename: C:\buildslave\unity\build\Runtime/Export/Debug.bindings.h Line: 45)
    This code definitely worked before, so I'm not sure if it's a Unity bug or if I messed up somewhere. Can anyone confirm if this is working correctly in 2018.3.7?