Version: 2018.4
public void OnPointerClick (EventSystems.PointerEventData eventData);




Use this callback to detect clicks.

Make sure you have an Event System in your Scene.

using UnityEngine;
using UnityEngine.EventSystems;

public class Example : MonoBehaviour, IPointerClickHandler { //Detect if a click occurs public void OnPointerClick(PointerEventData pointerEventData) { //Output to console the clicked GameObject's name and the following message. You can replace this with your own actions for when clicking the GameObject. Debug.Log(name + " Game Object Clicked!"); } }