Hi, I encountered this bug on multiple version of Unity pre-releases and the UI Toolkit previews but originally I thought this is so obvious it might get fixed without me reporting it. However it still seems to not work correctly and at the moment I can’t find a good workaround for it either.
I am working on a project with an ingame-menu which works via pressing a pointer down anywhere on the screen opening a menu to allow selecting an menu option while the pointer is still pressed. When the pointer/touch is released the menu disappears again and the active item selection is triggered. For registering the active selection I am listening to the PointerEnterEvent and PointerLeaveEvent on the items wrapper VisualElement.
However, I noticed that these events only work well in the editor using a mouse but not when I run a build on mobile (Android) using the native touch interface. In that case only the PointerMoveEvent is fired.
Unity - 2020.2.1f1
UI Toolkit - Version 1.0.0-preview.13
Input System - Version 1.0.1
I created a minimal sample project so it can easily be reproduced: GitHub - doctorseus/unity-pointer-event-issues
This demo project is using the new Input System package but this is also not working with the old input system.
The bug can also be reproduced via the Device Simulator package.
Please let me know if you have any suggestions. I am also wondering if I can use a work-around in the meanwhile but I am struggling to find a proper way to detect the last/first PointerMoveEvent to interpret it as an LeaveEvent/EnterEvent without going back to the old immediate way of checking on each frame.
I edited the title to highlight that the events are only not fired while a pointer is pressed (which is not really relevant on mobile but it is noticeable if you only click on a VisualElement it will actually fire the Enter and Leave events, even on mobile).
In the meanwhile I also reported this via Unity, Case 1304962.
I don’t believe this is on the same level. I tried to reproduce this with this sample but Unity Remote touch events don’t work at all (the would not even detect Pointer.current.press.wasPressedThisFrame to open the menu in this case).
Hi MousePods, thanks for the reference, 1288234 looks like it is this issue. It is unfortunate that this still waits for a fix as I can’t really find a way to work around this issue. Would be great to see an update on this.
At the moment I am trying to generating my own VisualElement events via the external input system but the current UI toolkit does not expose a way to transform a screen pointer to a panel scale pointer (they are all marked internal to UIElements) so I can not check if the VisualElement below the pointer is the element I am looking for. (Everywhere the framework assumes you have a mouse position already in panel world space).
Edit: The bug can also be reproduced via the Device Simulator package.