UI Buttons vs OnMouseDown?

Hello.

Does anyone know why we might use OnMouseDown over Unity’s button component or vice versa?

Thank you.

Hi,

Have you already looked the method up in the API? From the description:

This event is sent to all scripts of the GameObject with Collider or GUIElement.

Button is a GUIElement.

Did this help? :slight_smile:


See also:

I think so.

So the button script is just sitting there waiting for the OnMouseDown event. But I can create other scripts that rely on the event as well, as long as my game object has a collider or a GUI Element.

Thank you for your help.

Exactly. :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms