Issue with tooltip showing & dragging item

Hey, I have a weird issue where if I keep “blocks raycast” on the inventory item prefab, the tooltip is patchy, and doesn’t always show. When I turn it off, the tooltip is perfect, but I now cannot drag the item. Was there a workaround I might have missed earlier in the course? It looks like when I mouseover the item in my inventory some part of the “InventoryItem” prefab is blocking the mouse from registering being over the item, and not allowing the tooltip to spawn.

Out of curiousity, are you using Unity 2021.2 or later?
There is a bug in the way Unity2021.2 handles OnPointerExit with masked images.

If this is the case, locate the file TooltipSpawner in the Utils/Tooltip directory of the Inventory script package and change the IPointerExitHandler.OnPointerExit method to look like this:

void IPointerExitHandler.OnPointerExit(PointerEventData eventData)
{
    var slotCorners = new Vector3[4];
    GetComponent<RectTransform>().GetWorldCorners(slotCorners);
    Rect rect = new Rect(slotCorners[0], slotCorners[2] - slotCorners[0]);
    if (rect.Contains(eventData.position)) return;
    ClearTooltip();
}

This will trick the system into believing that it is still hovering over the item when it is still within the frame.

2 Likes

yeah I’m using 2021.2.11f1, and this 100% fixed it. Thank you very much!

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms