【发布时间】:2017-01-10 18:57:09
【问题描述】:
就像上图一样,我们前面有一个模型和一个画布。它在脚上有对撞机,我还需要按钮中的 onclick 事件。我想要的是当用户单击按钮时游戏对象没有动作,但现在很难单击按钮。
下面是我的代码:
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 中的按钮