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一起使用。