unity 点击3D物体

  1. 在场景中添加事件系统

2. 为主相机添加射线检测

  1. 为物体挂载以下脚本,物体必须带碰撞体
cs 复制代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;


// 挂在物体上,需要添加碰撞体
public class DoorAction :  MonoBehaviour, IPointerDownHandler
{
    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        
    }

     public void OnPointerClick(PointerEventData eventData)
    {
    	//你要触发的代码
        print("xxx");
    }
    
	//当检测到鼠标在该物体上有"按下"操作时,触发以下函数
    public void OnPointerDown(PointerEventData eventData)
    {
    	//你要触发的代码
         print("xxx");
    }

}
相关推荐
慧都CAD开发笔记29 分钟前
3D InterOp读取STEP模型:能显示,为什么一划分网格就失败?
3d
xcLeigh10 小时前
Unity基础:Instantiate实例化——在运行时动态创建游戏物体
游戏·unity·游戏引擎·教程·instantiate
Shirley~~11 小时前
three.js的调试面板工具
前端·3d
云飞云共享云桌面13 小时前
智能装备数字化转型:云飞云云桌面助力苏州工厂共享 SolidWorks 算力
运维·服务器·3d·自动化·制造
Zldaisy3d14 小时前
哈工大黄永江课题组 l 多元素原位合金化调控增材制造TC4多尺度组织
3d·制造
杀生丸学AI14 小时前
【三维重建】GaussianGPT:迈向自回归三维高斯场景生成
深度学习·3d·transformer·三维重建·自回归·高斯泼贱
Jmyd012315 小时前
智慧文博3D扫描系统架构:从采集到平台的全链路方案
3d·系统架构·3d扫描·智慧文博
流浪打工人1 天前
Unity3d TimeLine中audio track的使用
unity
总要学点什么1 天前
第51篇:数据分析-热力图——笔刷画的是圆,落到地上却成了椭圆
3d·数据挖掘·数据分析·前端框架·gis·webgl·cesium
淡海水1 天前
02-07-原理篇-GC暂停时间的本质
开发语言·unity·c#·gc·暂停时间