Tooltip not closing

@Brian_Trotter
I implemented the fix to my tooltip closing inconsistent behavior from here:

using 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();
        }

It’s working but introduced another issue for me, my tooltip sometimes gets stuck and does not close even though my mouse is not already over the item.

It happens mostly when hovering over the item on action my bar.

Which version of Unity are you using? Wondering if they introduced new breaking behaviour again…

Try adding this debug to the method to make sure it’s getting called when you aren’t getting the clearance… this may be a Physics system issue.

Debug.Log($"{name} OnPointerExit {Time.time}");

I did add it. sometimes pointer exit is okay sometimes It’s not being called and the tooltip gets stuck being displayed.
I’m using Unity 2021.3.0f1.

It’s difficult to see for sure because the video is blurry until just AFTER the last mouseover, so I can’t read the time stamps… it looks like the OnPointerExit isn’t firing at all when it leaves. It’s possible that the event isn’t firing at all, perhaps if the mouse is moving too quickly…

Let’s experiment…

        private void LateUpdate()
        {
            if (tooltip && !EventSystem.current.IsPointerOverGameObject())
            {
                  ClearTooltip();
            }
        }

This is what I would call the brute force approach. If the tooltip isn’t over any game object, then let’s murder it.

1 Like

You’re right it’s not being called and this instantly solves it.
I am testing it and it’s not getting stuck anymore at this time.

What could be causing this? maybe I am calling some code that interferes with its intended functionality.
As I’m in the middle parts of the shop’s and abilities course I will keep testing and update if it comes back. Thank you.

It’s a bug in that version of Unity, most likely. There’s nothing in our code that would interfere with the Physics system.

1 Like

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

Privacy & Terms