# Can Event Triggers be used on Non-UI objects?

Is there any way to use UI-Based event triggers on Non-UI objects?

Example : on any UI object, you add an EventTrigger component, set the event, and then set the actions for the event. Its easy, and clean, to make UI do various actions on things like mouse enter / exit, drag, etc.

For non UI objects (a cube, for example) these kind of things are mostly done through scripts with raycast code. Its not impossible, but I find it messier, harder to organize, and less flexible then the EventTrigger approach.

I'm working on a turn based strategy type game. Much of the game mechanics is based around mouse movement and clicking. I tried just adding an on-click event to a cube, but it didn't do anything.

Is this scenario just plain not supported?

• Presumably you tried firing your event in OnMouseDown? – DMGregory Sep 2 at 20:33
• i assume not. but you can simply simulate them on non-UI objects. they have their own Callbacks – virtouso Sep 2 at 21:13
• I realize there are events on Monobehavior like OnMouseDown, OnMouseOver, etc. My problem with these is that the 'when' and 'what' get coupled together. I imagine its possible to uncouple these things. But if it would instead just work with the event-triggers, I wouldn't be re-inventing the wheel. – Sperry Sep 2 at 23:05

You can do this if you add a Physics Raycaster component to your camera. Just make sure you have colliders on the same GameObjects that have the EventTriggers you want to be clickable.

You also have the option to do this with 2D physics using a Physics 2D Raycaster.

• This worked perfect. Thanks! – Sperry Sep 3 at 2:41