UGUI检测当前是否点中UI

UGUI判断当前是否有点中UI

<code>    // true:当前点中了UI
    public static bool IsTouchOnUI()
    {
        //check mouse PC平台检测鼠标
        if (EventSystem.current.IsPointerOverGameObject())
        {
            return true;
        }

        //check touch 手机检测每个touch
        if (Input.touchCount > 0 &amp;&amp; Input.touches&#91;0].phase == TouchPhase.Began)
        {
            if (EventSystem.current.IsPointerOverGameObject(Input.touches&#91;0].fingerId))
            {
                return true;
            }
        }

        return false;
    }</code>
发表评论?

0 条评论。

发表评论


注意 - 你可以用以下 HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>