Search Issue Tracker
By Design
Votes
1
Found in
5.3.0f4
Issue ID
752390
Regression
Yes
IsPointerOverGameObject() takes the previous position of the Pointer instead of its current position
How to reproduce:
1. Open attached project
2. Build to iOS and run
3. Click inside the square that appears in the scene
- Note that the square remains on the screen (as it should)
4. Click outside the square
- Note that the square disappears (as it should)
5. Click outside the square area to make the square reappear
6. Click inside the square area again
- Note that the square disappears now, even though it shouldn't
- Reproduced in Version 5.4.0a5 (6b220773f9c9), Version 5.3.0f4 (2524e04062b4) on an iPad Pro (iOS9), iPhone6S (iOS9), Samsung Galaxy S6 Edge (Lollipop)
- Not reproducible in Version 5.2.3f1 (f3d16a1fa2dd)
- If IsPointerOverGameObject() is used without a parameter it defaults to -1 which points to the "left mouse button"; therefore the recommended usage of IsPointerOverGameObject for touch is to pass a pointerId to it
- Also, for touch, IsPointerOverGameObject should be used with OnMoveDown() or Input.GetMouseButtonDown or touch.phase == TouchPhase.Started
- We will update the documentation to make this clear
Comments (1)
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- WebGL build dependencies are not refreshed until the Editor is restarted
- “Audio Random Container” allows adding unlimited number in “Audio Clips” numeric field, causing Editor to freeze
- In Deferred rendering path, mixed lights don't render when enabling "Use Rendering Layers" in the Decal renderer feature
- [Windows] Special characters in file names are sorted to the end of the alphabet in the Project window
- Information box icons are not contained within the information box bounds in Render Pipeline Converter window
kromobrn
Feb 14, 2016 20:27
Isn't it correlated with how OnPointer events (especifically OnPointerExit) are handled on mobile devices?
In the game I'm developing with 5.3.2f1 I noticed that:
After touching an EventSystem object on a mobile device (touch input, no cursor), even that the OnPointerExit event is fired right after OnPointerUp (when releasing the finger), it seems like something isn't updated internally and if you try to verify if the next touch is over an EventSystem object, IsPointerOverGameObject (withTheTouchIdHere) will return true regardless the new touch position, as if it was over the EventSystem object previously touched.
If this new touch position is outside this EventSystem object, if you release the finger the OnPointerExit event will be fired again to the EventSystem object, now, "updating" things internally.
It's Interesting that that if you touch the EventSystem object and move your finger outside it, causing OnPointerExit to be fired before OnPointerUp, the IsPointerOverGameObject function behave correctly.
I'm not sure if this happens on other versions of Unity (may even be my mistake on coding), but I think it's worth reading for who is having similar issues with IsPointerOverGameObject() function.