移動端
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防穿透的效果。