当我在Unity中实际尝试游戏时,一切都很好。当我构建游戏并尝试它时,每个分辨率都显示两次,并且它们是颠倒的(例如:1920x1080是320x200,1680x1050是320x240,依此类推)。我会在这里给你我的代码:
public Dropdown resolutiondropdown;
Resolution[] resolutions;
void Start()
{
resolutions = Screen.resolutions;
resolutiondropdown.ClearOptions();
int currentresolutionindex = 0;
List<string> options = new List<string>();
for(int i=resolutions.Length-1;i>=0;i--)
{
string option = resolutions[i].width + " x " + resolutions[i].height;
options.Add(option);
if (resolutions[i].width == Screen.width && resolutions[i].height == Screen.height)
currentresolutionindex = i;
}
resolutiondropdown.AddOptions(options);
resolutiondropdown.value = currentresolutionindex;
resolutiondropdown.RefreshShownValue();
}
public void SetResolution(int resolutionindex)
{
Resolution resolution = resolutions[resolutionindex];
Screen.SetResolution(resolution.width, resolution.height, Screen.fullScreen);
}下面是我拍摄的屏幕截图:Settings menu
发布于 2019-02-18 20:23:25
这个家伙在这个视频中实现了分辨率设置,试试吧:https://www.youtube.com/watch?v=YOaYQrN1oYQ
所以,我不能重复你的问题-你的解决方案也很好用
这是你的代码的默认构建:

尝试在播放机设置中检查您的“分辨率和演示”
这是解析表的源代码- unity只是从你的电脑上取来的:
/// <summary>
/// <para>All full-screen resolutions supported by the monitor (Read Only).</para>
/// </summary>
public static extern Resolution[] resolutions { [FreeFunction("ScreenScripting::GetResolutions"), MethodImpl(MethodImplOptions.InternalCall)] get; }这就是为什么只有一种解决方案--手动检查重复项并将其从列表中删除
https://stackoverflow.com/questions/54735847
复制相似问题