【Unity】强制设定分辨率

来源:互联网 发布:程序员岗位职责 编辑:程序博客网 时间:2024/05/13 21:42

因为在项目中 需要发布到mac 平台 但是 mac本子 的屏幕是16:10 而原有的项目是按照16:9的尺寸做的 当然最好的方法就是 把图片重新换成以16:10的方式去替换掉 但是那样会修改的东西 比较大 下面用代码 强制设定分辨率为16:9(当然这种方法并不好因为UI图会被拉伸)

using UnityEngine;using System;using System.Collections;public class GTResolutionVersion : MonoBehaviour{    private float standard_width;    private float standard_height;     void Start()     {         GetPlatform();     }    public void GetPlatform()    {        //如果是mac 系统#if UNITY_STANDALONE_OSX        Resolution[] reslution = Screen.resolutions;        standard_width = reslution[reslution.Length - 1].width;        standard_height = ((standard_width * 9) / 16);        Screen.SetResolution(Convert.ToInt32(standard_width), Convert.ToInt32(standard_height), false);#endif        Application.LoadLevel(1);    }}

关于  


 Resolution[] reslution = Screen.resolutions;        standard_width = reslution[reslution.Length - 1].width;
0 0
原创粉丝点击