public void OnPointerExit(PointerEventData eventData)
 {
     pointerDownOnUIElement = null;
     if (currentlyHoveringSlot == this)
     {
         currentlyHoveringSlot = null;
     }
 }
        public virtual void OnPointerDown(PointerEventData eventData)
        {
            if (itemCollection == null)
            {
                return;
            }

            pointerDownOnUIElement = currentlyHoveringSlot;
            if (pointerDownOnUIElement == null)
            {
                return;
            }


            //////////// Ugly hack, because input modules will take over soon.
            bool tapped = OnTap(eventData, InventoryActionInput.EventType.OnPointerDown); // Mobile version of OnPointerUp

            if (tapped)
            {
                return;
            }

            if (isDoubleTap)
            {
                OnDoubleTap(eventData, InventoryActionInput.EventType.OnPointerDown);
                return;
            }

            var s = InventorySettingsManager.instance.settings;

            if (s.useContextMenu && s.triggerContextMenuKeys.AllPressed(eventData, InventoryActionInput.EventType.OnPointerDown))
            {
                if (item != null)
                {
                    TriggerContextMenu();
                    return;
                }
            }

            lastDownTime = Time.timeSinceLevelLoad;
        }
        protected virtual void OnDisable()
        {
            if (useCustomUpdate)
            {
                StopCustomUpdate();
            }

            if (currentlyHoveringSlot == this)
            {
                currentlyHoveringSlot = null;
            }

            if (pointerDownOnUIElement == this)
            {
                pointerDownOnUIElement = null;
            }

            if (InventoryUIDragUtility.isDraggingItem)
            {
                InventoryUIDragUtility.OnEndDrag(new PointerEventData(EventSystem.current));
            }
        }
        public virtual void OnPointerUp(PointerEventData eventData)
        {
            // Started on a UI element?
            if (pointerDownOnUIElement == null)
            {
                return;
            }

            pointerDownOnUIElement = null;
//            lastDownTime = 0f;

            // Cursor still inside the button on Pointer up?
            var canvas = gameObject.GetComponentInParent <Canvas>();

            if (canvas.renderMode == RenderMode.ScreenSpaceOverlay)
            {
                if (screenSpaceRect.Contains(eventData.position) == false)
                {
                    return;
                }
            }

            if (isDoubleTap)
            {
                OnDoubleTap(eventData, InventoryActionInput.EventType.OnPointerUp);
                return;
            }

            bool tapped = OnTap(eventData, InventoryActionInput.EventType.OnPointerUp); // Mobile version of OnPointerUp

            if (tapped)
            {
                return;
            }

            var s = InventorySettingsManager.instance.settings;

            if (s.useContextMenu && s.triggerContextMenuKeys.AllPressed(eventData, InventoryActionInput.EventType.OnPointerUp))
            {
                if (item != null)
                {
                    TriggerContextMenu();
                    return;
                }
            }

            if (item != null && InventoryUIDragUtility.isDraggingItem == false)
            {
                // Check if we're trying to unstack
                if (itemCollection.useReferences == false && InventorySettingsManager.instance.settings.useUnstackClick && itemCollection.canUnstackItemsInCollection)
                {
                    if (InventorySettingsManager.instance.settings.unstackKeys.AllPressed(eventData, InventoryActionInput.EventType.OnPointerUp))
                    {
                        TriggerUnstack(itemCollection);
                        return; // Stop the rest otherwise we'll do 2 actions at once.
                    }
                }

                // Use the item
                if (InventorySettingsManager.instance.settings.useItemKeys.AllPressed(eventData, InventoryActionInput.EventType.OnPointerUp))
                {
                    TriggerUse();
                }
            }
        }