防止UI穿透操作到游戏场景

时间:2022-03-04 21:20:47

#if UNITY_EDITOR || UNITY_STANDALONE_WIN
if (EventSystem.current.IsPointerOverGameObject())
{
return ;
}
#else
if ((Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began))
{
if (EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId))
{
return ;
}
}
#endif