UGUI判断当前是否有点中UI
<code> // true:当前点中了UI
public static bool IsTouchOnUI()
{
//check mouse PC平台检测鼠标
if (EventSystem.current.IsPointerOverGameObject())
{
return true;
}
//check touch 手机检测每个touch
if (Input.touchCount > 0 && Input.touches[0].phase == TouchPhase.Began)
{
if (EventSystem.current.IsPointerOverGameObject(Input.touches[0].fingerId))
{
return true;
}
}
return false;
}</code>
0 条评论。