随着时间的推移,我想把我的角色移动到一个点上。但我不想它的目标,如果接触点是UI元素。我成功地用鼠标点击PC,但不是触摸Android。
无问题的PC鼠标点击:
if (Input.GetMouseButton(0)) {
if (!EventSystem.current.IsPointerOverGameObject()){
Target = Camera.main.ScreenToWorldPoint(Input.mousePosition);
}
}
点击时仍向用户界面移动的安卓触摸:
if (Input.touchCount > 0){
foreach (Touch touch in Input.touches){
int id = touch.fingerId;
if (!EventSystem.current.IsPointerOverGameObject(id))
{
Target = Camera.main.ScreenToWorldPoint(touch.position);
}
}
}