zoukankan      html  css  js  c++  java
  • unity EditorWindow 绘制时间刻度

    最终效果图

    绘制时间刻度其实主要靠,Handles类的DrawLine(),Handles类里还封装了许多其它的图形绘制方法,如画扇形等

    知道这个方法就很简单了

        private void DrawfraemLine(Rect rect)
        {
            Handles.BeginGUI();
            Handles.color = new Color(0,1,0,0.4f);
            float step = 8;
            int Index = 0;
            for (float i = rect.x+2; i < rect.width; i+=step)
            {
                if (Index%5 == 0)
                {
                    Handles.DrawLine(new Vector3(i, rect.y + rect.height - 20), new Vector3(i, rect.y + rect.height - 5));
                    string str = Index.ToString();
                    if (str.Length>2)
                    {
                        GUI.Label(new Rect(i - 15, rect.y + 12, 30, 12), str);
                    }
                    else if(str.Length>1)
                    {
                        GUI.Label(new Rect(i - 10, rect.y + 12, 20, 12), str);
                    }
                    else
                    {
                        GUI.Label(new Rect(i - 5, rect.y + 12, 12, 12), str);
                    }
                    
                }
                else
                {
                    Handles.DrawLine(new Vector3(i, rect.y + rect.height - 15), new Vector3(i, rect.y + rect.height - 10));
                }
                Index++;
                
            }
            
            Handles.EndGUI();
        }
  • 相关阅读:
    tomcat监控与优化
    rpm打包
    Rewrite和location 区别
    LNMP服务
    yum仓库脚本
    用户管理的脚本2
    pxe装机脚本
    用户管理的脚本1
    磁盘管理综合测试题
    MySQL 增量备份介绍及案例演示
  • 原文地址:https://www.cnblogs.com/DazeJiang/p/14083221.html
Copyright © 2011-2022 走看看