121 lines
3.3 KiB
C#
121 lines
3.3 KiB
C#
|
||
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);
|
||
}
|
||
|
||
}
|
||
|
||
|