Unity UGUI 判断鼠标是否点击到UI上

private bool IsTouchedUI()
    {
        bool touchedUI = false;
        //TODO 移动端
        if (Application.isMobilePlatform)  
        {
            if (Input.touchCount > 0 && EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId))
            {
                touchedUI = true;
            }
        }
        //TODO PC端
        else if (EventSystem.current.IsPointerOverGameObject())
        {
            touchedUI = true;
        }
        return touchedUI;
    }
发布了40 篇原创文章 · 获赞 36 · 访问量 21万+

猜你喜欢

转载自blog.csdn.net/yzx5452830/article/details/82012990
今日推荐