UGUI 判断点击在UI上还是屏幕中

private void Update()
    {

        if (Input.GetMouseButtonDown(0))
        {
#if !UNITY_EDITOR//手机模式
            if (!EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId))
#else//编辑器模式
            if (!EventSystem.current.IsPointerOverGameObject())
#endif
            {
                //没有点击到UI上
            }                      
        }
    }

猜你喜欢

转载自blog.csdn.net/cuijiahao/article/details/120502961