I totally understand why projects come with a lot of the hard work implement and help us focus on the core parts.
My question relates to the Event System and Event Trigger.
If I wanted to recreate a brand new project with the event system and an game object with an event trigger, I just can’t trigger the event when the mouse hovers over or mouse press the game object.
Create Empty object and name it Event System. Add Event System and Input Standalone Module components
Create a quad or a cube, whichever. Add a 3d box collider, script with a public void TriggerMe method. Add a Event Trigger component, create a trigger, choose the event, drag on the script that is attach to the object and pick the method from the list.
When I run the game, and look at the information on the Event System, I do get any messages when the mouse performs any of the trigger events on the game object.
What is the key mistake I am making. I thought I have replicated the Tower Defence project but am missing something. Can someone help. I have reverted for now to the OnMouseDown method in the script attached the object which works but would like to use the event system.
I love the effort the team has placed into every book and every project I have the opportunity to recreate. Thank you.
To get this to work you need a public method with this signature:
public void OnPointerClick([PointerEventData)
Everything you put in there will be called when you click on the attached collider.
You might also need to add a PhysicsRaycaster component on your main camera GameObject so the event system picks up clicks on 3D colliders.
There are also a bunch more interfaces you can derive from for additional behavior, check out the list on the left of this page: