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();
        }
  • 相关阅读:
    ubuntu下pip的安装和使用
    跨域总结
    本地存储小结
    SVN
    appium整理文档
    appium python andiroid自动化文档整理笔记
    Python 接口测试(二)
    Python 接口测试(一)
    Python 接口测试(四)
    Python 接口测试(三)
  • 原文地址:https://www.cnblogs.com/DazeJiang/p/14083221.html
Copyright © 2011-2022 走看看