1
就像上面的图片,我们有一个模型,并在它前面的画布。它在脚下有对撞机,我也需要在按钮上点击事件。我想要的是当用户点击按钮时,gameobject无动作,但现在很难单击该按钮。
这里是我下面的代码:
if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began)
{
EventSystem es = EventSystem.current;
Debug.Log("IsPointerOverGameObject === " + es.IsPointerOverGameObject(Input.GetTouch(0).fingerId));
Debug.Log("currentSelectedGameObject === " + es.currentSelectedGameObject);
if (!(es.IsPointerOverGameObject(Input.GetTouch(0).fingerId) && es.currentSelectedGameObject != null))
{
Debug.Log("Handle touch === ");
HandleTouchEvent();
}
}
是否有人有任何想法?
他们只是按钮? –
@TimCooley是的,ScrollRect中的按钮 –