ElectricityBusinessHall_Dig.../Assets/Resources/Scripts/IconClick.cs

121 lines
3.3 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 TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using ZenFulcrum.EmbeddedBrowser;
/// <summary>
/// 模型点击视角居中,单体化展示
/// </summary>
public class IconClick : MonoBehaviour
{
//0显示设备信息1显示人员信息2摄像头
public int type;
//漫游相机
public Camera _RoamCamera;
//旋转360
public Camera _RoundCamera;
//是否可点击
public bool isenable=false;
string name;
void Start()
{
//if (_camera==null) { _camera = Camera.main; }
}
private void Awake()
{
}
void Update()
{
//RaycastHit hit;
//向鼠标点击的位置发射一条射线 && 射线检测到的物体是当前挂着该脚本的物体
//if (Physics.Raycast(_camera.ScreenPointToRay(Input.mousePosition), out hit))
//{
// if (Input.GetMouseButtonDown(0))
// {
// if (hit.collider.name == transform.name)
// {
// if (type == 0)
// {
// //Debug.Log("!!!!!!!");
// //Main.intance.m_htmlPanel.CallFunction("showDeviceInfo");
// }
// }
// }
// }
}
private void OnMouseUp()
{
if (EventSystem.current.IsPointerOverGameObject())
{
Debug.Log("鼠标在UI上");
return;
}
ViewCenter();
if (!isenable)
return;
if (type == 0)
{
//Main.intance.m_htmlPanel.CallFunction("showDeviceInfo");
Main.intance.m_htmlPanel.CallFunction("U3DShowEquipmentDetails",0);
}
if (type == 1)
{
//Main.intance.m_htmlPanel.CallFunction("showPeopleInfo");
Main.intance.m_htmlPanel.CallFunction("U3DShowPeopleDetails",0);
}
if (Main.intance.CurentSingleObj != null)
{
Main.intance.CurentSingleObj.layer = LayerMask.NameToLayer("Default");
}
Main.intance.CurentSinglePage.SetActive(true);
//将当前物体设置为单体化360观察的物体
Main.intance.CurentSingleObj = gameObject;
_RoundCamera.GetComponent<Camera360>().SetTarget(transform);
//_RoundCamera.GetComponent<Camera360>().SetTarget(transform.GetComponent<MeshRenderer>().bounds.center);
gameObject.layer = LayerMask.NameToLayer("single360");
Main.intance.GaussianBlurPanel.transform.GetChild(2).Find("right").gameObject.SetActive(true);
//_RoamCamera.enabled = false;
//_RoundCamera.enabled = true;
//测试
//ViewCenter();
}
/// <summary>
/// 视角居中
/// </summary>
void ViewCenter()
{
Debug.Log("model"+transform.parent.name);
//获取模型中心点位置(加上模型方向*3
Vector3 playerPos = transform.parent.position+transform.parent.forward*3;
Quaternion angle = Quaternion.Euler(transform.parent.eulerAngles.x, transform.parent.eulerAngles.y - 180, transform.parent.eulerAngles.z);
Debug.Log("pos" + playerPos + ";angle" + angle);
//Main.intance.mainCamera.GetComponent<CameraView>().CamerMoveAnim(playerPos, angle);
Main.intance.CameraMoveAnim(playerPos, angle);
}
}