This project provides some examples of implementing and using EventSystem events (IPointerClickHandler and similar)
Clone/download whole project and open in Unity 6000.2.7 or later and open "Scenes/3DEventSystemExample".
This project provides the following implementation examples:
- EventSystemButtonExample: Clickable 3D cube (using IPointerClickHandler)
- EventSystemDragExample: Draggable 3D sphere (using IDragHandler, IBeginDragHandler, IEndDragHandler).
The core requirements to use these IPointer events are:
- An EventSystem instance in a loaded scene
- PhysicsRaycaster or Physics2DRaycaster component on your camera
- 3D or 2D collider on the GameObject that should recieve IPointer events.
Warning
Ensure the EventMask layers configured on your 3d/2d physics raycaster are correct as this controls what layers can be "hit". This affects what can block events and what can recieve events.
UI will block these pointer events if the UI layer is configured in EventMask (this is the default)
