1.通过EventSystem.current.IsPointerOverGameObject()的监听
/****************************************************
文件:ISOnclickUI.cs
作者:黄欣
日期:2019/08/23 8:56
功能:判断是否点击在UI上
*****************************************************/
using UnityEngine;
using UnityEngine.EventSystems;
public class ISOnclickUI : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
void Update()
{
if (Input.GetMouseButtonDown(0) || (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began))
{
#if IPHONE || ANDROID
if (EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId))
#else
if (EventSystem.current.IsPointerOverGameObje