为了账号安全,请及时绑定邮箱和手机立即绑定

Unity3D编译时出现Script error: OnTriggerEnter

Unity3D编译时出现Script error: OnTriggerEnter

C#
哆啦的时光机 2023-08-13 10:12:29
我有一个包含此代码的 MonoBehaviour;    private void OnTriggerEnter(Collider other)    {        Debug.Log(other.name);    }当我编译此代码时,我收到此错误:Script error: OnTriggerEnterThis message parameter has to be of type: ColliderThe message will be ignored.即使 MonoBehaviour 没有在任何地方使用,情况也是如此。(通过代码添加)添加它的代码:    private void SpawnItem(Vector3Int pos)    {        new GameObject().AddComponent<ItemGameobject>().Initialize(pos, new Item(GetBlockTypeAt(pos), 1));    }
查看完整描述

1 回答

?
侃侃尔雅

TA贡献1801条经验 获得超15个赞

您可能已将脚本命名为“Collider”。因此,您只需重命名脚本,因为它与 Unity 基本类型“Collider”冲突。



查看完整回答
反对 回复 2023-08-13
  • 1 回答
  • 0 关注
  • 132 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信