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");
    }

}
相关推荐
zhangfeng11331 小时前
aigc 从2d 到 3d的形式转变,李飞飞在介绍WorldLabs的Marble平台,会围绕“空间智能“的核心理念,自动驾驶就是2d形式
3d·自动驾驶·aigc
jtymyxmz1 天前
《Unity Shader》8.4 透明度混合
unity·游戏引擎
世洋Blog1 天前
利用<<左移运算符优雅的设计游戏能力的任意组合和判断
游戏·unity·c#
da_vinci_x1 天前
PS 3D Viewer (Beta):概念美术的降维打击,白模直接在PS里转光打影出5张大片
人工智能·游戏·3d·prompt·aigc·材质·游戏美术
GISer_Jing1 天前
3D Cesium渲染架剖析
javascript·3d·webgl
背影疾风1 天前
基于深度学习的3D点云特征提取方法梳理
人工智能·深度学习·3d·自动驾驶
逻辑羊驼1 天前
Hunyuan3D本地部署
3d
毛甘木1 天前
Unity MonoPInvokeCallback 使用教程
c++·unity
心疼你的一切1 天前
Unity开发Rokid应用之离线语音指令交互模型
android·开发语言·unity·游戏引擎·交互·lucene