private void SlotRemoveCallback(ItemSlot slot)
        {
            for (int i = 0; i < managers.Count; i++)
            {
                ItemSlotManager manager = managers[i];

                if (manager.slot == slot)
                {
                    manager.Detatch();
                    Destroy(manager.gameObject);
                    managers.RemoveAt(i);

                    OnSlotRemove(manager);

                    return;
                }
            }

            filterDirty = true;
        }
        public void Filter(SortingMode mode, ItemCondition[] Filters)
        {
            lastSorting = mode;
            LastFilters = Filters;

            sorted = new List <ItemSlot> ();

            for (int i = 0; i < current.Items.Count; i++)
            {
                ItemSlot slot = current.Items[i];

                if (HideEmpty && slot.Item == null)
                {
                    continue;
                }

                if (Filters == null)
                {
                    sorted.Add(slot);
                    continue;
                }

                if (Filters.IsValid(slot.Item))
                {
                    sorted.Add(slot);
                }
            }

            if (mode == SortingMode.Name)
            {
                sorted.Sort(NameComparison);
            }
            else if (mode == SortingMode.Type)
            {
                sorted.Sort(TypeComparison);
            }

            for (int i = 0; i < managers.Count; i++)
            {
                ItemSlotManager manager = managers[i];

                if (EventSystem.current.currentSelectedGameObject == manager.gameObject)
                {
                    EventSystem.current.SetSelectedGameObject(null);
                }
                manager.Detatch();
                manager.gameObject.SetActive(false);
            }

            for (int i = 0; i < sorted.Count; i++)
            {
                ItemSlotManager manager = managers[i];

                manager.gameObject.SetActive(true);

                manager.Setup(sorted[i]);

                /*if (i == 0)
                 * {
                 * EventSystem.current.SetSelectedGameObject(manager.gameObject);
                 * var pointer = new PointerEventData(EventSystem.current);
                 * //ExecuteEvents.Execute(manager.gameObject, pointer, ExecuteEvents.pointerEnterHandler);
                 * //ExecuteEvents.Execute(manager.gameObject, pointer, ExecuteEvents.selectHandler);
                 * }*/
            }

            filterDirty = false;
        }