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

参数

eventData 当前事件数据。

描述

使用此回调可检测单击。

请确保场景中具有事件系统。

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