其实就很简单的一句话
如
private IEnumerator OnMouseDown()
{
if (!EventSystem.current.IsPointerOverGameObject())
{
//选中被点击的物体
}
}
就是加上EventSystem.current.IsPointerOverGameObject()这个判断 这段代码是 具有给定ID的指针是否位于EventSystem对象上 也就是说判断鼠标指针是否在UI上