E_ElecCompetition/Electrical_inspectionCompet.../Assets/Adam/Scripts/Components/ThreeDTips.cs

47 lines
1.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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<ToolModelClick>())
{
Debug.Log(hit.collider.name);
}
}
}
}
}