public bool IsPointerOverGameObject();
public bool IsPointerOverGameObject(int pointerId);
1、参数
pointerId | Pointer (touch / mouse) ID. |
2、描述
具有给定ID的指针是否位于EventSystem对象上。
如果使用不带参数的IsPointerOverGameObject() ,则它指向“鼠标左键”(pointerId=-1);因此,当使用IsPointerOverGameObject进行触摸时,应考虑向其传递pointerId。
注意,IsPointerOverGameObject应该与OnMouseDown() 或 Input.GetMouseButtonDown(0) 或 Input.GetTouch(0).phase == TouchPhase.Began一起使用。