Unity 之 EventSystem.IsPointerOverGameObject

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章