我正在创建一个1920x1080分辨率的Unity项目(和我的显示器一样)。在Unity编辑器中测试程序时,一切看起来都很好-然而,一旦构建好,分辨率就会变成不可用的状态。
我有一个改变分辨率的选项,但是,我不认为这是问题所在,因为在改变设置之前,分辨率就被搞乱了。
这里有一些代码片段,如果我忽略了一些东西,它们可能是问题的原因。代码来自此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);
}
发布于 2019-07-27 12:14:22
为了解决这个问题,我刚刚使用了Unity内置的“显示分辨率对话框”。
这可能看起来有点懒惰,但是,它完美地解决了问题,并提供了图形选项更改。
也许将来,我会回来并加入分辨率设置,但现在启动游戏前的简短弹出窗口是很好的。
发布于 2019-07-26 14:11:08
您需要在独立播放器设置的Resolution and Presentation section中设置分辨率
您将能够设置窗口在从独立构建打开时的显示方式。
发布于 2019-07-27 11:57:55
您可以通过Start()中的脚本设置分辨率,并编写此行Screen.SetResolution(1920,1080,false);
,它将把您的默认分辨率设置为1920x1080。试试这个吧,我希望这对你有帮助。
https://stackoverflow.com/questions/57221509
复制