public void OnPointerClick (EventSystems.PointerEventData eventData);

Parámetros

eventDataCurrent event data.

Descripción

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!"); } }