模型点击事件监听
触发模型点击事件的必要条件
需要触发模型点击事件的模型身上必须要挂载Collider 组件

方法一
通过 OnMouseDown 函数监听(只能在PC端有效)
1.在Hierarchy 面板中右键,点击 3D Object->Cube 按钮,创建一个 Cube 模型
2.新建一个脚本,命名为“Test.cs”(代码如下)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Test2 : MonoBehaviour
{
private void OnMouseDown()
{
Debug.Log("OnMouseDown");
}
}




































苏公安网备 32011402010933号