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

Parámetros

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