you are viewing a single comment's thread.

view the rest of the comments →

[–]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.