if (Input.GetMouseButtonDown(0))
{
PointerEventData pointer = new PointerEventData(EventSystem.current);
pointer.position = Input.mousePosition;
List<RaycastResult> raycastResults = new List<RaycastResult>();
EventSystem.current.RaycastAll(pointer, raycastResults);
if (raycastResults.Count > 0)
{
foreach (var item in raycastResults)
{
Debug.Log("点击" + item.gameObject.name);
}
//if (raycastResults[0].gameObject.tag == "InventoryItem")
// raycastResults[0].gameObject.transform.position = Input.mousePosition;
}
else
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
Debug.Log(hit.collider.gameObject.name);
}
}
}
UGUI屏蔽Ray检测
最新推荐文章于 2023-04-18 10:09:28 发布