物体添加Collider

ui遮挡射线问题:关掉UI上面Raycast Target

在场景添加 EventSystem
Physics Raycaster 组件 添加在相机上
在被检测的物体上添加如下脚本

//引用命名空间
using UnityEngine.EventSystems;

public class EventTest : MonoBehaviour, IPointerClickHandler
{
      
     public void OnPointerClick(PointerEventData eventData)
    {
     UnityEngine.Debug.Log("哎呀,被点击啦!!!");

    }
}

点击物体弹出UI,再次点击UI触发某事件

相关文章:

  • 2021-10-11
  • 2021-04-05
  • 2021-07-21
  • 2021-11-07
  • 2021-09-30
  • 2021-04-17
  • 2021-10-02
  • 2021-11-07
猜你喜欢
  • 2022-12-23
  • 2021-07-14
  • 2021-04-05
  • 2021-11-23
  • 2022-12-23
  • 2021-04-23
  • 2021-06-08
相关资源
相似解决方案