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

        这样就可以自适应了!

  • 相关阅读:
    GDB 用法
    C编程规范
    PHP面向对象
    cron定时任务
    Apatche配置基础
    正则表达式笔记
    PHP在windows下命令行方式
    面试题
    struts与ajax的关系
    ORACLE DUAL表详解
  • 原文地址:https://www.cnblogs.com/alongu3d/p/3070289.html
Copyright © 2011-2022 走看看