I tested my game for the first time on mobile and the UI almost doesn't work. I use if(!EventSystem.current.IsPointerOverGameObject()) to check if I'm clicking on the UI (because if I don't click on the UI it moves my object to where I clicked and I don't want it to move when I click a button) and it works well on pc but on android not only it moves behind the button, but the buttons supposed to make it rotate just don't seem to respond. Sometimes I have to double tap the button to make it work once. Why doesn't it work as well as on pc ? Should it be the exact same thing ?

I didn't include screenshots or code because I have no idea where the problem might be coming from but I can provide these on demand.


There is a completely different subsystem for touch-based UI in Unity, which supercedes the older system you are using. This applies in most APIs, not just Unity, that have traditionally supported UI event-based inputs, and which had to be upgraded in the last decade or so to support touch. HTML5 contains another common example of this sort of supercession.

Put in another way: Since IsPointerOverGameObject() refers to a pointer, but your mobile screen has no actual pointer i.e. "mouse arrow", but rather only a list of touches, your approach will not work. You need to address your input from scratch in a manner that works for touch, either by building your own using Touch and its associated classes, or by grabbing something from e.g. the Wiki or the Asset Store that does that work for you.

  • \$\begingroup\$ IsPointerOverGameObject does also have an overload that accepts a pointer ID argument, so you can use this with multitouch interfaces to check whether a particular tracked touch (eg. finger) is on the UI. I think we'd need to see more of the context where Samuel Fyckes is using this in their code to recommend how to update this function call to be multitouch-aware. \$\endgroup\$ – DMGregory Jun 21 at 1:20
  • \$\begingroup\$ So the what I understand from Engineer answer is that right now, my code checks if I am over the button when I click and the proceeds to click, so when I touch the screen, it's like i'm instantly clicking and can't check if my touch is over the button before ? What context would you like me to add to my question? \$\endgroup\$ – Samuel Fyckes Jun 21 at 15:13
  • \$\begingroup\$ No, the problem is that you're checking the whether the mouse pointer is over the UI — the answer to that is always "no" on Android, because there is no mouse. What you want to ask is whether "this" finger touch that you're responding to is over the UI. To help you with that, we'd need to see where you're using IsPointerOverGameObject in your code. Try sharing a Minimal Complete Verifiable Example: every line of code and step of scene setup we'd need in order to replicate the problem in a new empty project. With that in hand, we can test potential solutions to be sure they'll work for you. \$\endgroup\$ – DMGregory Jun 21 at 19:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.