EventSystem eventSystem;
public GraphicRaycaster RaycastInCanvas;
bool CheckGuiRaycastObjects()//测试UI射线
{
PointerEventData eventData = new PointerEventData(eventSystem);
eventData.pressPosition = Input.mousePosition;
eventData.position = Input.mousePosition;
List<RaycastResult> list = new List<RaycastResult>();
RaycastInCanvas.Raycast(eventData, list);
//Debug.Log(list.Count);
return list.Count > 0;
}
···
返回为真表示点击在ui上
网友评论