Unity3d GUI适应分辨率

来源:互联网 发布:知客文化传播 培训 编辑:程序博客网 时间:2024/06/06 00:35
float sourceWidth = 1024f;    float sourceHeight = 768f;    float m_fScaleWidth;    float m_fScaleHeight;    void OnGUI()    {        m_fScaleWidth = Screen.width / sourceWidth;        m_fScaleHeight = Screen.height / sourceHeight;        GUI.matrix = Matrix4x4.TRS(new Vector3(0, 0, 0), Quaternion.identity,new Vector3(m_fScaleWidth, m_fScaleHeight, 1));        GUI.Button(new Rect(0, 0, 1024, 768), "");    }

0 0
原创粉丝点击