移动端
if (EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId))
return;
PC端
if (EventSystem.current.IsPointerOverGameObject())
return;
在操控代码前,加上这个判断。
如果点到了UI,就会阻断后面的操控代码执行,实现UI防穿透的效果。
移动端
if (EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId))
return;
PC端
if (EventSystem.current.IsPointerOverGameObject())
return;
在操控代码前,加上这个判断。
如果点到了UI,就会阻断后面的操控代码执行,实现UI防穿透的效果。