Resolution changes once program is built

时光毁灭记忆、已成空白 提交于 2020-07-03 17:29:10

问题


I am creating a Unity project in the 1920x1080 resolution (the same as my monitor). Everything looks fine when testing the program in the Unity editor - however, once built the resolution changes to an unusable state.

I have an option to change the resolution, however, I don't think this is the problem as the resolution is messed up before even changing the setting.

Screenshots: In Unity , Built

Here are some snippets of code which could be the cause of the problem if I've over looked something. The code is from this 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);
}


回答1:


You need to set the resolution in the Resolution and Presentation section of the Standalone Player settings

You will be able to set how the window will display when opening up from a standalone build.




回答2:


You can set the resolution via script in Start() and write this line Screen.SetResolution(1920,1080,false); that will be set you default resolution to 1920*1080. try this one i hope this will help you.




回答3:


To solve the problem, I've just used Unity's inbuilt 'display resolution dialogue'.

This may seem a little lazy, however, it's solved the problem perfectly and also offers graphics option changes.

Maybe in the future, I'll come back and incorporate resolution settings, but as of now the short popup before launching the game is fine.



来源:https://stackoverflow.com/questions/57221509/resolution-changes-once-program-is-built

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!