Ejemplo n.º 1
0
        private void DrawItem(MenuItem item, Rect groupRect)
        {
            if (item.separator)
            {
                if (Event.current.type == EventType.Repaint)
                {
                    RTEditorGUI.Seperator(new Rect(backgroundStyle.contentOffset.x + 1, currentItemHeight + 1, groupRect.width - 2, 1));
                }
                currentItemHeight += 3;
            }
            else
            {
                Rect labelRect = new Rect(backgroundStyle.contentOffset.x, currentItemHeight, groupRect.width, itemHeight);

                if (labelRect.Contains(Event.current.mousePosition))
                {
                    selectedPath = item.path;
                }

                if (selectedPath == null)
                {
                    Debug.Log("SELECTED PATH == NULL");
                    return;
                }
                bool selected = selectedPath == item.path || selectedPath.Contains(item.path + "/");
                GUI.Label(labelRect, item.content, selected? NodeEditorGUI.nodeLabelSelected : NodeEditorGUI.nodeLabel);

                if (item.group)
                {
                    GUI.DrawTexture(new Rect(labelRect.x + labelRect.width - 12, labelRect.y + (labelRect.height - 12) / 2, 12, 12), expandRight);
                    if (selected)
                    {
                        item.groupPos = new Rect(groupRect.x + groupRect.width + 4, groupRect.y + currentItemHeight - 2, 0, 0);
                        groupToDraw   = item;
                    }
                }
                else if (selected && ((Event.current.type == EventType.MouseDown && Event.current.button != 1) || (Event.current.button != 1 && Event.current.type == EventType.MouseUp)))
                {
                    item.Execute();
                    close = true;
                    Event.current.Use();
                }

                currentItemHeight += itemHeight;
            }
        }
Ejemplo n.º 2
0
        private void DrawItem(MenuItem item, Rect groupRect)
        {
            if (item.separator)
            {
                if (Event.current.type == EventType.Repaint)
                {
                    RTEditorGUI.Seperator(new Rect(backgroundStyle.contentOffset.x + 1, currentItemHeight + 1, groupRect.width - 2, 1));
                }
                currentItemHeight += 3;
            }
            else
            {
                Rect labelRect = new Rect(backgroundStyle.contentOffset.x, currentItemHeight, groupRect.width, itemHeight);

                bool selected = selectedPath.Contains(item.path);
                if (labelRect.Contains(Event.current.mousePosition))
                {
                    selectedPath = item.path;
                    selected     = true;
                }

                GUI.Label(labelRect, item.content, selected? selectedLabel : GUI.skin.label);

                if (item.group)
                {
                    GUI.DrawTexture(new Rect(labelRect.x + labelRect.width - 12, labelRect.y + (labelRect.height - 12) / 2, 12, 12), expandRight);
                    if (selected)
                    {
                        item.groupPos = new Rect(groupRect.x + groupRect.width + 4, groupRect.y + currentItemHeight - 2, 0, 0);
                        groupToDraw   = item;
                    }
                }
                else if (selected && (Event.current.type == EventType.MouseDown || (Event.current.button != 1 && Event.current.type == EventType.MouseUp)))
                {
                    item.Execute();
                    close = true;
                    Event.current.Use();
                }

                currentItemHeight += itemHeight;
            }
        }
 private void DrawItem(MenuItem item, Rect groupRect)
 {
     if (item.separator)
     {
         if (Event.current.type == EventType.Repaint)
         {
             Vector2 contentOffset = backgroundStyle.contentOffset;
             RTEditorGUI.Seperator(new Rect(contentOffset.x + 1f, currentItemHeight + 1f, groupRect.width - 2f, 1f));
         }
         currentItemHeight += 3f;
     }
     else
     {
         Vector2 contentOffset2 = backgroundStyle.contentOffset;
         Rect    rect           = new Rect(contentOffset2.x, currentItemHeight, groupRect.width, itemHeight);
         if (rect.Contains(Event.current.mousePosition))
         {
             selectedPath = item.path;
         }
         bool flag = selectedPath == item.path || selectedPath.Contains(item.path + "/");
         GUI.Label(rect, item.content, (!flag) ? GUI.skin.label : selectedLabel);
         if (item.group)
         {
             GUI.DrawTexture(new Rect(rect.x + rect.width - 12f, rect.y + (rect.height - 12f) / 2f, 12f, 12f), expandRight);
             if (flag)
             {
                 item.groupPos = new Rect(groupRect.x + groupRect.width + 4f, groupRect.y + currentItemHeight - 2f, 0f, 0f);
                 groupToDraw   = item;
             }
         }
         else if (flag && (Event.current.type == EventType.MouseDown || (Event.current.button != 1 && Event.current.type == EventType.MouseUp)))
         {
             item.Execute();
             close = true;
             Event.current.Use();
         }
         currentItemHeight += itemHeight;
     }
 }