if (Input.GetMouseButtonDown(0) || (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began))
{
if (EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId)) //这里是针对手机的事件
{
//当触碰的是UGUI时,产生操作
}
else
{
//当触碰到别的地方时,产生操作。
}
}
{
if (EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId)) //这里是针对手机的事件
{
//当触碰的是UGUI时,产生操作
}
else
{
//当触碰到别的地方时,产生操作。
}
}
}
if
(EventSystem.current.IsPointerOverGameObject())//把上面的针对手机的换成这个,就是指在电脑上的鼠标点击事件,鼠标点击在ugui上产生操作