判断鼠标点击的是UI还是模型

鼠标点击到了UI上还是模型上(如果模型和UI重叠了,点击到的是UI)

	if (Input.GetMouseButtonUp(0))
        {
    
    
            //判断点击的是否是UI
            if (UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject())
            {
    
    
                Debug.Log("点击到了UI上");
            }
            else
            {
    
    
                Debug.Log("点击到了3D物体上");
            }
        }

猜你喜欢

转载自blog.csdn.net/LWKlwk11/article/details/90052931
今日推荐