1、Unity中分辨率有专门的格式:Resolution
Resolution resValue = new Resolution();
2、String转Resolution
常规字符串形式的分辨率无法自动转化识别
这里拆分String,然后根据string里的对应数值设置Resolution
Resolution.width = int.Parse("分辨率宽度");
Resolution.height = int.Parse("分辨率高度");
Resolution.refreshRate = int.Parse("分辨率的垂直刷新率");
3、功能函数
/// <summary>
/// 字符串形式的分辨率转分辨率格式
/// </summary>
/// <param name="stringValue"></param>
/// <returns></returns>
private Resolution StringToResolution(string stringValue)
{
Resolution resValue = new Resolution();
resValue.width = int.Parse(stringValue.Split('X')[0]);
resValue.height = int.Parse(stringValue.Split('X')[1].Split('(')[0]);
string temp = stringValue.Split('(')[1];
resValue.refreshRate = int.Parse(temp.Split(')')[0]);
return resValue;
}