unity判断是否点击到某个按钮

      1、适应场景:当点击到界面其他地方,这个按钮不再突出显示,怎么解决?

private void Update()

    {

        if (Input.GetMouseButtonDown(0))

        {

            if (EventSystem.current.currentSelectedGameObject == null || EventSystem.current.currentSelectedGameObject.name != "ButtonName")

            {

                Debug.Log("没有点击到这个按钮");

            }

        }

    }

扫描二维码关注公众号,回复: 14899903 查看本文章

猜你喜欢

转载自blog.csdn.net/qq_39646949/article/details/128986501
今日推荐