Event Trigger

The Event Trigger component can be attached to any UI (or non-UI) element to allow the object to receive events. Some of the UI elements are preconfigured to intercept specific events. For example, buttons have the onClick event. However, if you'd like to add an event to an object that either isn't already set up to receive events or you want it to receive different events, you can attach an Event Trigger component to the GameObject.

You can attach an Event Trigger component by selecting Add Component | Event | Event Trigger.

One caveat of using the Event Trigger component is that the object it is attached to receives all the events, not just the ones you added. So, even if you don't tell the object what to do with the specified ...

Get Mastering UI Development with Unity now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.