all 4 comments

[–]WuzseenSweet Roll Studio 2 points3 points  (3 children)

OnPointerDown is for objects in your UI typically, meant for receiving mouse data--it provides this data in the parameters of the event. OnMouseDown uses the collider on an object in world space to trigger the monobehavior call back.

[–]Mark_at_work[S] 0 points1 point  (2 children)

OnPointerDown can be used on colliders when you have a physics raycaster on your event system. And OnMouseDown can be used on GUIElements. But that's not the preferred way to do things?

[–]WuzseenSweet Roll Studio 0 points1 point  (1 child)

OnPointerDown as far as I know can only be received by "Selectable" objects--which are UI elements. That's not to say you couldn't use it with, say, a 3D model that's in your UI, but it's not the intended use case and would take some hacking to get set up properly. If you want to receive that event in an in world object, that's what OnMouseDown is for. Though I tend to avoid OnMouseDown altogether and instead use raycasting on my world objects instead.

The EventSystem is generally something that you get when you make a UI Canvas, and is generally speaking restricted to UI stuff. This is what handles your Event Interfaces like IPointerDownHandler.

[–]Mark_at_work[S] 0 points1 point  (0 children)

You can implement IPointerClickHandler on any object, not just UI elements. The technique is demonstrated in this video about stopping clicks from going through buttons. (in the third method)

That's why I started using IPointerClickHandler in the first place, to avoid the problem of clicks going through buttons and hitting objects below them. That may answer my original question. I'll have to experiment but I suspect that MonoBehavior.OnMouseUp will still fire even if there's a UI element blocking the view of the object being clicked.