Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

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

Discussion in 'UGUI & TextMesh Pro' started by Strom_CL, Nov 6, 2022.

  1. Strom_CL

    Strom_CL

    Joined:
    Nov 17, 2012
    Posts:
    73
    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:
     
    Last edited: Nov 6, 2022
  2. Strom_CL

    Strom_CL

    Joined:
    Nov 17, 2012
    Posts:
    73
    Just wanted to add, my Camera followscript is using LateUpdate() for its transform.position movement.
     
  3. Strom_CL

    Strom_CL

    Joined:
    Nov 17, 2012
    Posts:
    73
    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.

    Code (CSharp):
    1.  
    2.     private void LateUpdate()
    3.     {
    4.         transform.position = playerTransform.position + new Vector3(0, depth, vertical);
    5.         transform.LookAt(playerTransform.position, Vector3.up);
    6.     }
    7.  
     
  4. Strom_CL

    Strom_CL

    Joined:
    Nov 17, 2012
    Posts:
    73
    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.

     
    Last edited: Nov 8, 2022
  5. karliss_coldwild

    karliss_coldwild

    Joined:
    Oct 1, 2020
    Posts:
    378
    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.
     
    Strom_CL likes this.
  6. Strom_CL

    Strom_CL

    Joined:
    Nov 17, 2012
    Posts:
    73
    Now to make sense of this, don't have much experience with UnityEvent Systems

    upload_2022-11-8_10-6-43.png
     
  7. Strom_CL

    Strom_CL

    Joined:
    Nov 17, 2012
    Posts:
    73
    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?

    upload_2022-11-8_11-27-4.png
     
  8. Strom_CL

    Strom_CL

    Joined:
    Nov 17, 2012
    Posts:
    73
    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.

     
  9. Strom_CL

    Strom_CL

    Joined:
    Nov 17, 2012
    Posts:
    73
    @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.
     
    Last edited: Nov 22, 2022