Why not using "OnMouse" for android?

Hi everyone,

I used to use the event triggers on the UI objects for 2D android projects, but now
I have a 3D project for android, and I’m using “OnMouse” event handlers.

While everything works flawless, the console recommends me not to use OnMouse for handheld devices.

My question is, why shouldn’t I use them? Because of perfomance or inaccurancy?
(I’m making a 3D-escape game, so accuracy is not that much needed.)

Also, if I shouldn’t use it, which alternative is there?
Do I always need to calculate where my object is as related to the screen and the use TouchInput?

I’m not entirely sure what the difference is. I may have seen it talked about before, but I forget.
What I remember is that the IPointer interfaces are preferred. Try IPointerDownHandler, as an interface on your script.
For a 3D game, make sure to add a physics raycaster to your camera, and any script with this interface must also have a collider on it, as I recall.
These work with both mouse and touch.

Thank you for your answer,

however, I still don’t know why I should bother tochange my code, if it is working without problems with OnMouseDown?
(Sorry if this senctence sounds impolite.)

Nope, no trouble. I mean, if you don’t think it’s being a pain, then there’s nothing saying you have to change it… :slight_smile:

You could, some day if you’re feeling adventurous – profile the two different methods and see if you can see a difference. I’ve never done this, so I have no idea :slight_smile: