UGUI如何判断鼠标或者手指是否点击到UI上

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class UiClickTest : MonoBehaviour {

    // Use this for initialization
    void Start () {
    
    }
    
    // Update is called once per frame
    void Update () {

        if (Input.GetMouseButtonDown(0)) {
            if (EventSystem.current.IsPointerOverGameObject()) {
                Debug.Log("点击到UGUI的UI界面,会返回true");
            } else {
                Debug.Log("如果没点击到UGUI上的任何东西,就会返回false");
            }
        }
    }
}

你可能感兴趣的:(UGUI如何判断鼠标或者手指是否点击到UI上)