Unity3D:输出按下时,点击到的UI

PointerEventData eventData = new PointerEventData(EventSystem.current);
eventData.pressPosition = pos;
eventData.position = pos;

List<RaycastResult> list = new List<RaycastResult>();
GraphicRaycaster CanvasUI = GetComponent<GraphicRaycaster>();
CanvasUI.Raycast(eventData, list);
for (int i = 0; i < list.Count; i++)
{
    Debug.Log(list[i].gameObject.name);
}

猜你喜欢

转载自blog.csdn.net/lzt20007/article/details/83412128