void ShowGroupContextMenu(Rect rect, string groupName, ISelectionGroup group)
        {
            var menu = new GenericMenu();

            menu.AddItem(new GUIContent("Select All"), false, () =>
            {
                Selection.objects = activeSelectionGroup.Members.ToArray();
                UpdateActiveSelection();
            });
            menu.AddSeparator(string.Empty);
            menu.AddItem(new GUIContent("Clear Group"), false, () =>
            {
                group.Clear();
            });
            menu.AddItem(new GUIContent("Configure Group"), false, () => SelectionGroupConfigurationDialog.Open(group, this));
            if (!string.IsNullOrEmpty(group.Query))
            {
                menu.AddItem(new GUIContent("Update Query Results"), false, () => SelectionGroupManager.ExecuteQuery(group));
            }
            else
            {
                menu.AddDisabledItem(new GUIContent("Update Query Results"), false);
            }
            if (group.Scope == SelectionGroupDataLocation.Editor)
            {
                menu.AddItem(new GUIContent("Move to Scene"), false, () =>
                {
                    SelectionGroupManager.ChangeGroupScope(group, SelectionGroupDataLocation.Scene);
                });
            }
            else
            {
                menu.AddItem(new GUIContent("Move to Editor"), false, () =>
                {
                    SelectionGroupManager.ChangeGroupScope(group, SelectionGroupDataLocation.Editor);
                });
            }

            menu.AddItem(new GUIContent("Delete Group"), false, () =>
            {
                SelectionGroupManager.Delete(group);
            });
            menu.DropDown(rect);
        }
        void HandleHeaderMouseEvents(Rect rect, string groupName, ISelectionGroup group)
        {
            var e = Event.current;

            if (rect.Contains(e.mousePosition))
            {
                switch (e.type)
                {
                case EventType.MouseDown:
                    switch (e.button)
                    {
                    case RIGHT_MOUSE_BUTTON:
                        ShowGroupContextMenu(rect, groupName, group);
                        break;

                    case LEFT_MOUSE_BUTTON:
                        if (e.clickCount == 1)
                        {
                            activeSelectionGroup = group;
                        }
                        else
                        {
                            SelectionGroupConfigurationDialog.Open(group, this);
                        }
                        break;
                    }

                    break;

                case EventType.MouseDrag:
                    DragAndDrop.PrepareStartDrag();
                    DragAndDrop.StartDrag(groupName);
                    DragAndDrop.objectReferences = group.Members.ToArray();
                    e.Use();
                    break;
                }
            }
        }