public void OnGUIDraw(Rect position)
        {
            GUI.Label(new Rect(0, 0, 124, 18), "", EditorStyles.toolbar);
            if (GUI.Button(new Rect(124, 0, 26, 18), StyleTools.gearIcon, EditorStyles.toolbarButton))
            {
                ShowGear();
            }
            Rect menuTreeRect = new Rect(0, 18, 150, position.height);

            if (menuTree != null)
            {
                menuTree.OnGUI(menuTreeRect, this);
            }
            if (!isPopup)
            {
                if (curMenuTreeItem != null)
                {
                    Rect mentTreeItemDrawRecr = new Rect(151, 1, position.width - 152, position.height - 3);
                    if (curMenuTreeItem.menuTreeItemDraw != null)
                    {
                        GUILayout.BeginArea(mentTreeItemDrawRecr, StyleTools.Skin.box);
                        curMenuTreeItem.menuTreeItemDraw.Invoke(new Rect(0, 0, mentTreeItemDrawRecr.width, mentTreeItemDrawRecr.height));
                        GUILayout.EndArea();
                    }
                    else
                    {
                        GUI.Label(mentTreeItemDrawRecr, GUILayoutTools.GetTextSizeOf(curMenuTreeItem.Name + " 内容未定制...", 30), StyleTools.MiddleCenterLab);
                    }
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 页码绘制接口,参数为当前页和最大页码。 注意:页码是从0开始的  显示上是从1开始的
 /// </summary>
 /// <param name="curPage">当前页</param>
 /// <param name="maxPage">最大页码</param>
 /// <returns>返回操作后的页码</returns>
 public static int DrawPage(int curPage, int maxPage)
 {
     if (maxPage <= 1)
     {
         return(0);
     }
     GUILayoutTools.Separator_SingleLine();
     using (new GUILayout.HorizontalScope())
     {
         GUILayout.FlexibleSpace();
         if (GUILayout.Button("第一页", EditorStyles.toolbarButton, GUILayout.Width(40)))
         {
             return(0);
         }
         if (GUILayout.Button("<<", EditorStyles.toolbarButton, GUILayout.Width(30)))
         {
             var page = curPage - 1;
             return(Mathf.Max(0, page));
         }
         bool draw = false;
         for (int i = 0; i < maxPage; ++i)
         {
             if (i == 0 || i == maxPage - 1 || Mathf.Abs(i - curPage) <= 2)
             {
                 bool select = i == curPage;
                 var  color  = GUI.color;
                 GUI.color = select ? Color.green : color;
                 if (GUILayout.Button((i + 1).ToString(),
                                      EditorStyles.label, GUILayout.Width(20)))
                 {
                     curPage = i;
                 }
                 GUI.color = color;
                 draw      = false;
             }
             else
             {
                 if (!draw)
                 {
                     draw = true;
                     GUILayout.Label("...", GUILayout.Width(20));
                 }
             }
         }
         if (GUILayout.Button(">>", EditorStyles.toolbarButton, GUILayout.Width(30)))
         {
             var page = curPage + 1;
             return(Mathf.Min(page, maxPage - 1));
         }
         if (GUILayout.Button("最后页", EditorStyles.toolbarButton, GUILayout.Width(40)))
         {
             return(maxPage - 1);
         }
         GUILayout.Space(20);
         GUILayout.FlexibleSpace();
     }
     return(Mathf.Clamp(curPage, 0, maxPage - 1));
 }
        public void OnGUI(Rect position)
        {
            TryInitPropTab();
            var objLenth = objectList.Count;

            using (new GUILayout.HorizontalScope())
            {
                foreach (var tab in tabList)
                {
                    if (tab.DrawTitle())
                    {
                        repaint();
                    }
                }
                GUILayout.FlexibleSpace();
            }
            GUILayoutTools.Separator_DoubleLine();
            var bgRect = GUILayoutUtility.GetLastRect();

            using (var sc = new GUILayout.ScrollViewScope(scroll))
            {
                for (var i = 0; i < objLenth; i++)
                {
                    var m        = objectList[i];
                    var selected = Selection.activeObject == m;
                    var style    = selected ? "SelectionRect" : GUI.skin.label;
                    var rowRect  = new Rect(bgRect.x - 10, (i * 20) - 2, bgRect.width, 20);
                    if (rowRect.Contains(Event.current.mousePosition) && !selected)
                    {
                        style = "box";
                    }
                    EditorGUI.DrawRect(rowRect, i % 2 == 0 ? rowColorTypeOne : rowColorTypeTwo);
                    GUI.Label(rowRect, "", style);
                    using (new GUILayout.HorizontalScope())
                    {
                        foreach (var tab in tabList)
                        {
                            using (new GUILayout.VerticalScope(GUILayout.Width(tab.width)))
                            {
                                tab.DrawProp(m, position);
                            }
                            GUILayoutUtility.GetRect(10, 20);
                        }
                        GUILayout.FlexibleSpace();
                        if (GUILayout.Button("Ping Object", EditorStyles.toolbarButton))
                        {
                            PingObject(m);
                            Event.current.Use();
                        }
                    }
                }
                scroll = sc.scrollPosition;
            }
            DrawExtend();
        }
Esempio n. 4
0
        public static bool SerachFiled(ref string search)
        {
            bool serachFlag = false;

            GUILayout.BeginVertical();
            Label(new GUIContent("Serach"));
            using (new HorizontalScope())
            {
                search = TextField(search, "", 100, GUILayout.Height(30));
                if (GUILayoutTools.SerachButton())
                {
                    serachFlag = true;
                }
            }
            GUILayout.EndVertical();
            return(serachFlag);
        }
Esempio n. 5
0
        protected override void RowGUI(RowGUIArgs args)
        {
            Rect rect     = args.rowRect;
            var  id       = args.item.id;
            bool isSelect = IsSelected(id);

            if (!isSelect)
            {
                if (rect.Contains(Event.current.mousePosition))
                {
                    EditorGUI.DrawRect(rect, hoverColor);
                }
            }
            GUI.Label(rect, GUILayoutTools.GetTextSizeOf(args.item.displayName, 16), StyleTools.MiddleCenterLab);
            if (menuTreeItems.FindIndex(t => { return(t.Id == id); }) != menuTreeItems.Count - 1)
            {
                GUITools.Separator_SingleLine(new Rect(rect.x, rect.y + rect.height - 1, rect.width, 10));
            }
        }
 public override void OnGUI(Rect rect)
 {
     position = rect;
     HandleDragRect();
     //CheckSize();
     if (drawer != null)
     {
         if (drawer.drawTitle)
         {
             GUILayoutTools.DrawTitle(drawer.Name, true);
         }
         if (drawer.menuTreeItemDraw != null)
         {
             drawer.menuTreeItemDraw(rect);
         }
     }
     else
     {
         GUI.Label(rect, GUILayoutTools.GetTextSizeOf("内容未定制...", 30), StyleTools.MiddleCenterLab);
     }
     editorWindow.Repaint();
 }