You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Unity分辨率过滤导致画面异常问题求助

Unity分辨率过滤导致画面异常问题求助

大家好,我最近在做Unity游戏的分辨率设置功能时遇到了一个棘手的问题,想请教下各位大佬。

我知道同一种分辨率可能会因为屏幕刷新率不同而重复出现在分辨率列表里,所以打算根据当前屏幕的刷新率来过滤列表,只保留匹配的分辨率选项。但现在遇到了奇怪的情况:当我启用过滤逻辑后,设置分辨率时游戏画面会变得模糊,侧边还会出现黑边;可如果不启用过滤,手动去选和过滤后完全一样的分辨率(刷新率也一致),画面却显示得很正常。目前代码里的过滤行是被注释掉的状态。

下面是我的完整代码:

resolutionDropdown.ClearOptions();

resolutions = Screen.resolutions;//.Where(resolution => resolution.refreshRate == Screen.currentResolution.refreshRate).ToArray();

List<string> options = new List<string>();

for (int i = 0; i < resolutions.Length; i++)
{
    Debug.Log("resolutions[i].refreshRate = " + resolutions[i].refreshRateRatio);
    Debug.Log(resolutions[i].width + " " + resolutions[i].height);
    string option = resolutions[i].width + " x " + resolutions[i].height + " " + resolutions[i].refreshRateRatio;
    options.Add(option);

    if (resolutions[i].Equals(Screen.currentResolution))
    {
        currResolutionIndex = i;
    }
}

resolutionDropdown.AddOptions(options);
resolutionDropdown.value = currResolutionIndex;
resolutionDropdown.RefreshShownValue();

if (currResolutionIndex == -1)
{
    Screen.SetResolution(Screen.width, Screen.height, isFullscreen);
}
else
{
    Screen.SetResolution(Screen.resolutions[currResolutionIndex].width, Screen.resolutions[currResolutionIndex].height, isFullscreen);
}

我试过把注释掉的过滤行打开,只保留和当前屏幕刷新率一致的分辨率,但一启用就会出现画面模糊、黑边的问题。有没有大佬能帮我分析下可能的原因,或者给个解决思路呀?

备注:内容来源于stack exchange,提问作者Nastya Makarova

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.21 15:24:32