UI panel OnPointerEnter/Exit glitches when player moves around, ideas?

I have a canvas object that has a panel, that has a Grid Layout Group on it, and in script I’m populating the grid with 60 inventory buttons that have an icon and an OnPointerEnter event in script. When I move my pointer over the inventoryButtons I set the scale of the tooltipWindow to (1,1,1), and its transform.position to the buttons transform.position so that the tooltip hovers over the inventoryButton. I set the scale to (0,0,0) in OnPointerExit to “hide” the window.

As you can see in the video, this works great up until I start moving around. You can see that I’m not moving my mouse, but Unity thinks I’m moving it over the adjacent buttons and its changing the tooltip to other items that are next to the item I’m moused over. I have a Debug.Log in OnPointerExit and it fires as I’m moving around with the mouse not moving, so its something weird going on.

I am at a loss as to how to fix this. It does it in both the editor and a standalone build. Anyone have any ideas? Would be much appreciated!

Video below:

Just wanted to add, my Camera followscript is using LateUpdate() for its transform.position movement.

I’m seeing this behavior with raycast as well to colliders that are setting other tooltips as well. This is my cameraFollowScript that I’ve tried in Update, LateUpdate, and FixedUpdate, and it still jitters.

    private void LateUpdate()
    {
        transform.position = playerTransform.position + new Vector3(0, depth, vertical);
        transform.LookAt(playerTransform.position, Vector3.up);
    }

Figured I’d rule out the camera so now I have the camera follow script disabled and the jitter still happens. Mind blown! So just using Input Axis controls for moving a rigidbody is causing OnPointerEnter/OnPointerExit blips. I also moved over to the new InputSystem and still get this behavior. I have two Debug.Log lines in OnPointerEnter/Exit and I see both of them being triggered without moving the mouse.

Take a look at the callstack when OnPointerExit event happens. That should give you some information about what kind of events are being processed when pointer exit is triggered. Most of the UGUI code is shipped in the package so it’s not too difficult to debug. You can even set a breakpoint in your OnPointerExit handler and once it hits, go back in stack and inspect the local variables of code which decides that pointerExit should happen.

1 Like

Now to make sense of this, don’t have much experience with UnityEvent Systems

Looks like its processing a leftbutton mouse event? It called ProcessMouseEvent first then fell down to left buttonData. I’m not touching my mouse or clicking any buttons. Looking at the code it looks like middle and right buttons only check MousePress and MouseDrag, why is Leftbutton checking for movement?

I think I finally found whats going on, but don’t have a fix for it. I have a Player prefab that spawns in for multiplayer, each player has their own screen space - overlay Canvas for their UI. I’ve attached a video showing that even though the canvas doesn’t move in the game or scene view, the transform values for position, rotation, and scale are constantly changing when the parent gameobject moves.

This looks like a bug and those values should be frozen when set to “Screen Space - Overlay”. There is no reason for them to change aside from scaling up to higher resolutions, these values should not be changing on the fly, only on a resolution change. I’ve filed a bug and will be attaching this new info to it.

@Stephan_B I spent a bit looking around the UGUI forums and it seems like you’re the most active Unity poster on the forums so figured I’d try @'ing you. I’ve submitted an editor bug and just thought I’d ping you, see if maybe you guys had a chance to take a look at this, or knew of a work around or solution to get around this. Much appreciated!

I’d be more than glad to provide any other info or chat with you guys if you’d like. I can’t upload my entire project as its a few gb, but hopefully I’ve added enough info/videos above to help.

UPDATE!: Been working back and forth with Unity getting them my project to get this replicated and they got it! Bug report acknowledged there: Unity Issue Tracker - OnPointerEnter/OnPointerExit is called when the mouse is not moving (unity3d.com)

I’ll post back here when I see fix in a release. If anyone is reading this, make sure to go vote up that bug! :slight_smile:

And they’ve said that its not important enough to fix and would cost too much time/money. Yet another example of Unity failing. This bug would probably take less than a half hour to fix, and at most a few hours if you wanted to retain the original broken logic and add a new preference flag.

1 Like