From e9ea621b93fbb58d9edfca8375918791637bbd52 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 30 Dec 2020 20:59:04 +0800 Subject: +init --- Client/Assembly-CSharp/ResolutionManager.cs | 44 +++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Client/Assembly-CSharp/ResolutionManager.cs (limited to 'Client/Assembly-CSharp/ResolutionManager.cs') 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 ResolutionChanged; + + public static void SetResolution(int width, int height, bool fullscreen) + { + Action 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); + } +} -- cgit v1.1-26-g67d0