Unity 怎样检测UGUI被点到了

一个简单Demo

if (Input.GetMouseButtonDown(0) )
        {
            Debug.Log(EventSystem.current.gameObject.name);
            if (EventSystem.current.currentSelectedGameObject)
                Debug.Log("当前触摸在UI上");
            else Debug.Log("当前没有触摸在UI上");
        }

你可能感兴趣的:(Unity 怎样检测UGUI被点到了)