public class PointColliderUtil
{
public static GameObject OnePointColliderObject()
{
PointerEventData eventDataCurrentPosition = new PointerEventData(EventSystem.current);
eventDataCurrentPosition.position = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
List<RaycastResult> results = new List<RaycastResult>();
try
{
EventSystem.current.RaycastAll(eventDataCurrentPosition, results);
}
catch (Exception ex)
{
}
if (results.Count > 0)
{
return results[0].gameObject
Unity点击物体点不到?帮你查看点击的物体的名字
最新推荐文章于 2024-07-15 18:13:27 发布
在Unity中,遇到点击事件无法正确识别目标物体的问题。本文将教你如何检查点击的物体并提供解决方案,确保点击事件正常工作。
摘要由CSDN通过智能技术生成