【问题标题】:Resolution changes once program is built构建程序后分辨率会发生变化
【发布时间】:2019-12-04 21:15:04
【问题描述】:

我正在创建一个分辨率为 1920x1080 的 Unity 项目(与我的显示器相同)。在 Unity 编辑器中测试程序时,一切看起来都很好 - 但是,一旦构建分辨率更改为不可用状态。

我可以选择更改分辨率,但是,我认为这不是问题,因为在更改设置之前分辨率就已经搞砸了。

截图: In Unity , Built

这里有一些 sn-ps 的代码,如果我看过一些东西,这可能是问题的原因。代码来自这个tutorial

void Start ()
{
     resolutions = Screen.resolutions;
     currentResolutionIndex = PlayerPrefs.GetInt(RESOLUTION_PREF_KEY, 0);
     SetResolutionText(resolutions[currentResolutionIndex]);
}
private void SetAndApplyResolution(int newResolutionIndex)
{
     currentResolutionIndex = newResolutionIndex;
     ApplyCurrentResolution();
}

private void ApplyCurrentResolution()
{
     ApplyResolution(resolutions[currentResolutionIndex]);
}

private void ApplyResolution(Resolution resolution)
{
     SetResolutionText(resolution);
     Screen.SetResolution(resolution.width, resolution.height, Screen.fullScreen);
     PlayerPrefs.SetInt(RESOLUTION_PREF_KEY, currentResolutionIndex);
}

【问题讨论】:

    标签: c# unity3d build screen-resolution


    【解决方案1】:

    需要在独立播放器设置的Resolution and Presentation section中设置分辨率

    您将能够设置从独立版本打开时窗口的显示方式。

    【讨论】:

      【解决方案2】:

      您可以通过 Start() 中的脚本设置分辨率并编写此行 Screen.SetResolution(1920,1080,false); 这会将您的默认分辨率设置为 1920*1080。 试试这个,希望对你有帮助。

      【讨论】:

        【解决方案3】:

        为了解决这个问题,我刚刚使用了 Unity 内置的“显示分辨率对话框”。

        这可能看起来有点懒惰,但是,它完美地解决了问题并且还提供了图形选项更改。

        也许将来,我会回来并合并分辨率设置,但到目前为止,启动游戏之前的短暂弹出窗口很好。

        【讨论】:

        • 该对话框在最新的 Unity 中不再存在...
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-10-07
        • 2017-10-09
        相关资源
        最近更新 更多