cancel
Showing results for 
Search instead for 
Did you mean: 

PointerExit events sent when clicking UI button (PointablecanvasModule.cs) SDK v63.0.0

Jepplen
Expert Protege

Found an issue when clicking a UI button with custom OnPointerEnter / OnPointerExit events.
Issue: PointerExit events getting triggered when clicking a button even though the pointer never leaves the button.

Setup:
Meta XR Interaction SDK 63.0.0

PointableCanavsModule (With EventSystem) and a Canvas with a standard Button.
The button has a custom script that registers OnPointerEnter and OnPointerExit events, each event is printing a message in the log: "ENTER" and "EXIT".
When clicking the button while keeping the pointer on the button (never breaking the hover) you get this log:

EXIT
EXIT
ENTER

It looks like the Exit event is hardcoded to be sent whenever a click has happened which I believe is a problem in itself, in addition I don't see why it would fire twice on top of that?

As far as I can see,
For UI to work you need to add PointableCanvasModule.cs from the Meta XR Interaction SDK.
This will call ProcessPointer on each of the pointers which if released (I assume this means "clicked") will call the base class in Unity UGUI package (EventSystem/InputModules/BaseInputModules.cs) using this call HandlePointerExitAndEnter(pointerEventData, null);
But it is always passing NULL as newEnterTarget and if null the code below gets executed and looks like it will send exit events no matter what.

I would say this is a bug in the Meta XR Interaction SDK / PointableCanvasModule.cs.
I cannot imagine this being a feature as it adds quite a bit complexity for using OnPointerEnter and OnPointerExit for custom hover functionality on clickable buttons.

BaseInputModules.cs

 

// walk up the tree till a common root between the last entered and the current entered is found
// send exit events up to (but not including) the common root. Then send enter events up to
// (but not including) the common root.
// Send move events before exit, after enter, and on hovered objects when pointer data has changed.
protected void HandlePointerExitAndEnter(PointerEventData currentPointerData, GameObject newEnterTarget)
{
    // if we have no target / pointerEnter has been deleted
    // just send exit events to anything we are tracking
    // then exit
    if (newEnterTarget == null || currentPointerData.pointerEnter == null)
    {
        var hoveredCount = currentPointerData.hovered.Count;
        for (var i = 0; i < hoveredCount; ++i)
        {
            currentPointerData.fullyExited = true;
            ExecuteEvents.Execute(currentPointerData.hovered[i], currentPointerData, ExecuteEvents.pointerMoveHandler);
            ExecuteEvents.Execute(currentPointerData.hovered[i], currentPointerData, ExecuteEvents.pointerExitHandler);
        }

        currentPointerData.hovered.Clear();

        if (newEnterTarget == null)
        {
            currentPointerData.pointerEnter = null;
            return;
        }
    }
...

 



The above might not be the reason for this behaviour, but the behaviour is there nonetheless.
Is this something that will be fixed?
Pretty sure this was not an issue when using OVRInputModule.cs instead of PointableCanvasModule.cs.

0 REPLIES 0