using UnityEngine; // 啟動時的全域設定 public static class GameBoot { [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] static void Init() { // 幀率上限 = 螢幕支援的最高更新率(120Hz 手機就跑 120) // 注意:Android 上 targetFrameRate = -1 代表平台預設 30fps,不是無限制; // 超過螢幕更新率的幀也看不到,只會增加耗電與發熱 QualitySettings.vSyncCount = 0; Application.targetFrameRate = Mathf.Max(60, MaxRefreshRate()); } static int MaxRefreshRate() { double max = Screen.currentResolution.refreshRateRatio.value; foreach (var r in Screen.resolutions) if (r.refreshRateRatio.value > max) max = r.refreshRateRatio.value; return Mathf.RoundToInt((float)max); } }