Screen.resolutions doesn't return full list in build
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):
Resolution[] resolutionsTemp = Screen.resolutions;
Vector2 prevRes = Vector2.zero;
string screenResolutions = "";
string selectableResolutions = "";
for (int i = 0; i < resolutionsTemp.Length; i++)
{
Vector2 resVec = new Vector2(resolutionsTemp[i].width, resolutionsTemp[i].height);
if (prevRes != resVec)
{
selectableResolutions += resolutionsTemp[i] + ", ";
}
prevRes = resVec;
screenResolutions += resolutionsTemp[i] + ", ";
}
print("All resolutions supported by monitor (retrieved via Screen.resolutions): \n" + screenResolutions);
print("All resolutions selectable in the game: \n" + selectableResolutions);
print("Total available resolutions: " + Screen.resolutions.Length);
And in the build, this gives me:
All resolutions supported by monitor (retrieved via Screen.resolutions):
2560 x 1440 @ 144Hz
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug.bindings.h Line: 45)
All resolutions selectable in the game:
2560 x 1440 @ 144Hz
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug.bindings.h Line: 45)
Total available resolutions: 1
(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 bug or if something else changed. Can anyone confirm if this is working correctly in 2018.3.7?
Your answer
Follow this Question
Related Questions
Can I submit a project on this forum, or via email, for someone to fix the Display issues?!? 0 Answers
Screen.SetScreenResolution breaks the view 0 Answers
Set Game Resolution For Every Screen 0 Answers
Objects are seen stretched on mobile view 0 Answers
How to scale canvas content according to screen resolution? 1 Answer