using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; //============================================================ //支持中文,文件使用UTF-8编码 //@author YangHua //@create 20230917 //@company QianHuo // //@description: //============================================================ namespace Components { public class ThreeDTips : MonoBehaviour { public Camera _camera; // Use this for initialization private void Start() { } private void Update() { // 从相机位置发射一条射线经过屏幕上的鼠标点击位置 Ray ray = _camera.ScreenPointToRay(Input.mousePosition); // 声明一个射线碰撞信息类 RaycastHit hit; // 进行碰撞检测 bool res = Physics.Raycast(ray, out hit); if (res) { // 如果产生了碰撞 if (hit.collider.GetComponent()) { Debug.Log(hit.collider.name); } } } } }