zoukankan      html  css  js  c++  java
  • 大大的蛋项目 第二篇 第三关

                                                                 大大的蛋项目 第二篇

         这个项目的UI要自动适应分辨率,我们采用了Unity3d自带的UI,对于GUI的自适应原则是这样的!

          GUI.matrix = Matrix4x4.TRS(new Vector3(0, 0, 0), Quaternion.identity, new Vector3(m_fScaleWidth, m_fScaleHeight, 1));

          其中m_fScaleWidth,m_fScaleHeight是屏幕运行是的分辨率与当前分辨率的比例系数!

           float m_fScreenWidth = 1440;
           float m_fScreenHeight= 900;
           float m_fScaleWidth;
           float m_fScaleHeight;

          void Awake ()
        {
         m_fScaleWidth = (float)((Screen.width)/m_fScreenWidth);
         m_fScaleHeight = (float)((Screen.height)/m_fScreenHeight);     
        }

        //UI控制界面.
        void OnGUI()
        {
        GUI.matrix = Matrix4x4.TRS(new Vector3(0, 0, 0), Quaternion.identity, new Vector3(m_fScaleWidth, m_fScaleHeight, 1));
        GUI.DrawTexture(new Rect(200,600,bgtex.width,bgtex.height),bgtex);
        }

        这样就可以自适应了!

  • 相关阅读:
    《让未来的你,感谢现在的自己》——自己努力
    老罗——《我的奋斗》
    1. opencv的初体验
    opencv初体验
    opencv的初体验
    python学习2——数据类型
    卷积的意义
    C#学习笔记一
    C++知识点
    二维数组作为参数传递
  • 原文地址:https://www.cnblogs.com/alongu3d/p/3070289.html
Copyright © 2011-2022 走看看