备份,准备做双端
This commit is contained in:
@@ -48,7 +48,11 @@ public class graphicSettings : MonoBehaviour
|
||||
}
|
||||
#endif
|
||||
|
||||
int screenMode = PlayerPrefs.GetInt(PrefKeyScreenMode, 0);
|
||||
// 无存档(首次运行)时,跟随 Player Settings 里的启动全屏模式,而不是硬编码窗口化(0)。
|
||||
// 否则会把 ProjectSettings 的独占全屏强切成窗口化,且窗口化分支无兜底分辨率,
|
||||
// 导致 Unity 回落到内建默认窗口尺寸 1280x720。
|
||||
int defaultScreenMode = MapFullScreenModeToIndex(Screen.fullScreenMode);
|
||||
int screenMode = PlayerPrefs.GetInt(PrefKeyScreenMode, defaultScreenMode);
|
||||
screenMode = Mathf.Clamp(screenMode, 0, 2);
|
||||
|
||||
try
|
||||
@@ -141,7 +145,7 @@ public class graphicSettings : MonoBehaviour
|
||||
screenMode_Dropdown.onValueChanged.AddListener(OnScreenModeChanged);
|
||||
}
|
||||
|
||||
private int MapFullScreenModeToIndex(FullScreenMode mode)
|
||||
private static int MapFullScreenModeToIndex(FullScreenMode mode)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
@@ -492,6 +496,19 @@ public class graphicSettings : MonoBehaviour
|
||||
|
||||
if (savedResIndex < 0)
|
||||
{
|
||||
// 无任何分辨率存档(首次运行,savedResIndex == -2)。
|
||||
// 全屏模式下 ApplyScreenModeStatic 已用显示器原生分辨率铺满,无需处理。
|
||||
// 但窗口模式下 ApplyScreenModeStatic 只是沿用启动瞬间的窗口尺寸(常为引擎默认 1280x720),
|
||||
// 这里兜底到 1920x1080(受当前显示器上限约束),避免默认落到 720p。
|
||||
if (Screen.fullScreenMode == FullScreenMode.Windowed)
|
||||
{
|
||||
const int FallbackW = 1920;
|
||||
const int FallbackH = 1080;
|
||||
Resolution cur = Screen.currentResolution;
|
||||
int w = Mathf.Min(FallbackW, cur.width);
|
||||
int h = Mathf.Min(FallbackH, cur.height);
|
||||
Screen.SetResolution(w, h, FullScreenMode.Windowed, cur.refreshRateRatio);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user