diff options
author | chai <chaifix@163.com> | 2020-12-30 20:59:04 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2020-12-30 20:59:04 +0800 |
commit | e9ea621b93fbb58d9edfca8375918791637bbd52 (patch) | |
tree | 19ce3b1c1f2d51eda6878c9d0f2c9edc27f13650 /Client/Assembly-CSharp/ResolutionManager.cs |
+init
Diffstat (limited to 'Client/Assembly-CSharp/ResolutionManager.cs')
-rw-r--r-- | Client/Assembly-CSharp/ResolutionManager.cs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/ResolutionManager.cs b/Client/Assembly-CSharp/ResolutionManager.cs new file mode 100644 index 0000000..15a8ce7 --- /dev/null +++ b/Client/Assembly-CSharp/ResolutionManager.cs @@ -0,0 +1,44 @@ +using System; +using UnityEngine; + +public static class ResolutionManager +{ + public static event Action<float> ResolutionChanged; + + public static void SetResolution(int width, int height, bool fullscreen) + { + Action<float> resolutionChanged = ResolutionManager.ResolutionChanged; + if (resolutionChanged != null) + { + resolutionChanged((float)width / (float)height); + } + Screen.SetResolution(width, height, fullscreen); + } + + public static void ToggleFullscreen() + { + bool flag = !Screen.fullScreen; + int width; + int height; + if (flag) + { + Resolution[] resolutions = Screen.resolutions; + Resolution resolution = resolutions[0]; + for (int i = 0; i < resolutions.Length; i++) + { + if (resolution.height < resolutions[i].height) + { + resolution = resolutions[i]; + } + } + width = resolution.width; + height = resolution.height; + } + else + { + width = 711; + height = 400; + } + ResolutionManager.SetResolution(width, height, flag); + } +} |