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);
        }

        这样就可以自适应了!

  • 相关阅读:
    ThinkPHP函数详解:C方法
    ThinkPHP函数详解:A方法
    php中的中文字符串长度计算以及截取
    JQ $("#form1 :input" ).length 与 $("#form1input").length有什么区别?
    php中的isset和empty的区别与认识
    谈谈ACM带来的一些东西
    HDU 4374--F(x)
    奖学金
    数字排序
    查找数字
  • 原文地址:https://www.cnblogs.com/alongu3d/p/3070289.html
Copyright © 2011-2022 走看看