| | 1 | | using System.Collections.Generic; |
| | 2 | | using MainScripts.DCL.Controllers.SettingsDesktop; |
| | 3 | | using UnityEngine; |
| | 4 | |
|
| | 5 | | namespace MainScripts.DCL.Controllers.HUD.SettingsPanelHUDDesktop.Scripts |
| | 6 | | { |
| | 7 | | public static class ScreenResolutionUtils |
| | 8 | | { |
| | 9 | | private static Resolution[] resolutions; |
| 0 | 10 | | public static IReadOnlyList<Resolution> Resolutions => resolutions ??= Screen.resolutions; |
| | 11 | |
|
| | 12 | | public static void Apply(DisplaySettings displaySettings) |
| | 13 | | { |
| 0 | 14 | | var fullscreenMode = displaySettings.GetFullScreenMode(); |
| | 15 | |
|
| 0 | 16 | | var resolution = GetResolution(displaySettings); |
| 0 | 17 | | Screen.SetResolution(resolution.width, resolution.height, fullscreenMode, resolution.refreshRate); |
| 0 | 18 | | } |
| | 19 | |
|
| | 20 | | // Resolution list goes from the smallest to the biggest, our index is inverted for usage reasons so 0 is the bi |
| | 21 | | private static Resolution GetResolution(DisplaySettings displaySettings) |
| | 22 | | { |
| 0 | 23 | | return Resolutions[Resolutions.Count - 1 - displaySettings.resolutionSizeIndex]; |
| | 24 | | } |
| | 25 | | } |
| | 26 | | } |