E_ElecCompetition/Electrical_inspectionCompet.../Assets/Script/KDLURL/newfollow.cs

49 lines
1.3 KiB
C#

using UnityEngine;
using UnityEngine.EventSystems;
public class newfollow : MonoBehaviour
{
[SerializeField] testURL game;
[SerializeField] string name;
public string url;
//[SerializeField] Dialogue dialogue;
// Start is called before the first frame update
//void Start()
//{
// //EventTriggerListener.Get(transform.gameObject).onClick += g =>
// //{
// //};
//}
private void Update()
{
// 鼠标左键按下
if (Input.GetMouseButtonDown(0))
{
// 从相机位置发射一条射线经过屏幕上的鼠标点击位置
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
// 声明一个射线碰撞信息类
RaycastHit hit;
// 进行碰撞检测
bool res = Physics.Raycast(ray, out hit) && !EventSystem.current.IsPointerOverGameObject();
if (res)
{
// 如果产生了碰撞
if (hit.transform.name.Equals(name))
{
Debug.Log(hit.transform.name);
//game.gameObject.SetActive(true);
//game.init(url);
}
}
}
}
//// Update is called once per frame
//private void FixedUpdate()
//{
// transform.LookAt(game);
//}
}