1242 lines
50 KiB
C#
1242 lines
50 KiB
C#
using DG.Tweening;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
|
|
/// <summary>
|
|
/// 点击脚本
|
|
/// </summary>
|
|
public class ClickEvent : MonoBehaviour
|
|
{
|
|
/// <summary>
|
|
/// 物体是否透明
|
|
/// </summary>
|
|
public bool isTransparentGlow = false;
|
|
|
|
/// <summary>
|
|
/// 放大状态
|
|
/// </summary>
|
|
public bool My_magnifyState = false;
|
|
|
|
private List<MeshRenderer> meshRenderers;
|
|
/// <summary>
|
|
/// 自身的
|
|
/// </summary>
|
|
private List<Material> materials;
|
|
/// <summary>
|
|
/// 复制出来的
|
|
/// </summary>
|
|
public List<Material> empty = new List<Material>();
|
|
public Shader TransparentGlow_Shader;
|
|
|
|
/// <summary>
|
|
/// 坐标偏移值
|
|
/// </summary>
|
|
//[SerializeField] Vector3 yiDong_pos = new Vector3(1.5f, 0.5f, 0);
|
|
//[SerializeField] Vector3 yiDong_pos = new Vector3(2.1f, 0.2f, 0);
|
|
[SerializeField] Vector3 yiDong_pos = new Vector3(2.1f, 1.1f, 0);
|
|
/// <summary>
|
|
/// 角度偏移值
|
|
/// </summary>
|
|
[SerializeField] Vector3 fangDa_rot = new Vector3(0, -90, 0);
|
|
|
|
public List<MeshRenderer> MeshRenderers
|
|
{
|
|
get
|
|
{
|
|
if (meshRenderers == null)
|
|
meshRenderers = GetComponentsInChildren<MeshRenderer>().ToList();
|
|
return meshRenderers;
|
|
}
|
|
}
|
|
|
|
public List<Material> Materials
|
|
{
|
|
get
|
|
{
|
|
if (materials == null)
|
|
{
|
|
materials = new List<Material>();
|
|
MeshRenderers.ForEach(render =>
|
|
{
|
|
Array.ForEach(render.materials, (_mat) =>
|
|
{
|
|
if (!materials.Contains(_mat))
|
|
{
|
|
materials.Add(_mat);
|
|
Material _emp = new Material(_mat);
|
|
empty.Add(_emp);
|
|
}
|
|
});
|
|
});
|
|
}
|
|
return materials;
|
|
}
|
|
}
|
|
|
|
public static Transform selected_cabient;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
|
|
TransparentGlow_Shader = Resources.Load<Shader>("TransparentGlow");
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
if (!EventSystem.current.IsPointerOverGameObject() && Input.GetMouseButtonDown(0) && TransparentGlowManage.Inst.gameObject.activeSelf)
|
|
{
|
|
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
|
RaycastHit hit/* = new RaycastHit()*/;
|
|
|
|
|
|
if (/*GameManager.Inst.magnifyState && */Menu.M_数字孪生_场景管理 != CabinetUIManager.Instance.current_menu && !DOTween.IsTweening(ExtendedFlycam.Inst.gameObject))
|
|
{
|
|
if (Physics.Raycast(ray, out hit, 100, 1 << 14 | 1 << 6 | 1 << 8 | 1 << 13 | 1 << 11))//机柜-6 门-14 蓄电池-15
|
|
{
|
|
if (hit.collider.gameObject.layer != 11 &&
|
|
(!GameManager.Inst.magnifyState || (GameManager.Inst.magnifyState && GameManager.Inst.FindParent(hit.collider.gameObject, GameManager.Inst.IsDesiredParent) == GameManager.Inst.nowCabine)) &&
|
|
!PatternChoose.Inst.sb_xz_page.activeSelf && !PatternChoose.Inst.sb_bj_page.activeSelf &&
|
|
!PatternChoose.Inst.dk_xz_page.activeSelf && !PatternChoose.Inst.dk_bj_page.activeSelf &&
|
|
!WebInteraction.Inst.isVideoPlay
|
|
)
|
|
{
|
|
if (hit.collider.gameObject.layer == 14 && hit.collider.transform.parent.gameObject == gameObject)
|
|
{
|
|
var d = gameObject.GetComponent<DeviceQuery>();
|
|
if (d)
|
|
{
|
|
PatternChoose.Inst.sb_ck_page.SetActive(false);
|
|
GameManager.Inst.now_CK_Device = gameObject;
|
|
Change_hide(gameObject, false, false, false);
|
|
}
|
|
//return;
|
|
}
|
|
//else if (GameManager.Inst.FindParent(hit.collider.gameObject, GameManager.Inst.IsDesiredParent) != GameManager.Inst.nowCabine)
|
|
// return;
|
|
else if (hit.collider.gameObject == gameObject && (gameObject.layer == 8 || gameObject.layer == 6 || gameObject.layer == 13))
|
|
{
|
|
var d = gameObject.GetComponent<DeviceQuery>();
|
|
if (d)
|
|
{
|
|
PatternChoose.Inst.sb_ck_page.SetActive(false);
|
|
GameManager.Inst.now_CK_Device = gameObject;
|
|
Change_hide(gameObject, false, false, false);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (Menu.M_数字孪生_场景管理 == CabinetUIManager.Instance.current_menu && GameManager.Inst.magnifyState)
|
|
{
|
|
if (Physics.Raycast(ray, out hit, 100, 1 << 8 | 1 << 14 | 1 << 13))//模型(设备)-8 门-14
|
|
{
|
|
if (hit.collider.gameObject.layer == 14) return;
|
|
if (hit.collider.gameObject == gameObject)
|
|
{
|
|
GameManager.Inst.nowDevice = null;
|
|
GameManager.Inst.nowDeviceID = null;
|
|
Debug.Log("点击到配置" + gameObject.name);
|
|
//PatternChoose.Inst.sb_bj_page.SetActive(false);
|
|
//PatternChoose.Inst.sb_xz_page.SetActive(false);
|
|
//PatternChoose.Inst.dk_bj_page.SetActive(false);
|
|
//PatternChoose.Inst.dk_xz_page.SetActive(false);
|
|
//PatternChoose.Inst.sb_ck_page.SetActive(false);
|
|
PatternChoose.Inst.clspup();
|
|
GameManager.Inst.now_CK_Device = null;
|
|
|
|
GameManager.Inst.search_box.SetActive(false);
|
|
var d = gameObject.GetComponent<DeviceQuery>();
|
|
var cabinet = GameManager.Inst.FindParent(gameObject, GameManager.Inst.IsDesiredParent);
|
|
DragController drag = GameManager.Inst.gameObject.GetComponent<DeviceManager>().dragController.GetComponent<DragController>();
|
|
|
|
if (d && GameManager.Inst.magnifyState)
|
|
{
|
|
if (string.IsNullOrEmpty(d.deviceList.id))
|
|
{
|
|
|
|
GameManager.Inst.lastDevice = gameObject;
|
|
GameManager.Inst.lastDeviceID = null;
|
|
|
|
GameManager.Inst.nowDevice = gameObject;
|
|
|
|
|
|
|
|
//PatternChoose.Inst.transform.Find("设备类/设备新增").gameObject.SetActive(true);//√
|
|
|
|
}
|
|
else
|
|
{
|
|
GameManager.Inst.lastDevice = gameObject;
|
|
GameManager.Inst.lastDeviceID = d.deviceList.id;
|
|
|
|
|
|
GameManager.Inst.nowDeviceID = d.deviceList.id;
|
|
GameManager.Inst.nowDevice = gameObject;
|
|
|
|
|
|
|
|
|
|
//PatternChoose.Inst.sb_bj_page.SetActive(false);.gameObject.SetActive(true);//√
|
|
}
|
|
if (string.IsNullOrEmpty(d.deviceList.id) && d.deviceList.deviceType == "3")
|
|
{
|
|
PatternChoose.Inst.sb_xz_page.SetActive(true);
|
|
GameManager.Inst.objectToShow_add.SetActive(false);
|
|
}
|
|
else if (!string.IsNullOrEmpty(d.deviceList.id) && d.deviceList.deviceType == "3")
|
|
{
|
|
PatternChoose.Inst.sb_bj_page.SetActive(true);
|
|
GameManager.Inst.objectToShow_add.SetActive(false);
|
|
}
|
|
else if (drag && GameManager.Inst.nowCabine == cabinet)
|
|
{
|
|
GameManager.Inst.now_CK_Device = gameObject;
|
|
PatternChoose.Inst.sb_ck_page.SetActive(false);
|
|
drag.uPosManger = GameManager.Inst.FindParent(gameObject, GameManager.Inst.IsFindParent_UPosManger).GetComponent<UPosManger>();
|
|
GameManager.Inst.gameObject.GetComponent<DeviceManager>().uposManger = drag.uPosManger;
|
|
//drag.oriObjectPrefab = gameObject.GetComponent<DragTest1>();
|
|
gameObject.GetComponent<DeviceItem>().OnselfClick();
|
|
GameManager.Inst.objectToShow_add.SetActive(true);
|
|
}
|
|
else
|
|
GameManager.Inst.editorMenu.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (Menu.M_数字孪生_线缆连接_配置 == CabinetUIManager.Instance.current_menu && GameManager.Inst.magnifyState && GameManager.Inst.FindParent(gameObject, GameManager.Inst.IsDesiredParent) == GameManager.Inst.nowCabine)
|
|
{
|
|
|
|
if (Physics.Raycast(ray, out hit, 100, 1 << 11 /*| 1 << 14*/))
|
|
{
|
|
if (hit.collider.gameObject.layer == 14) return;
|
|
if (hit.collider.gameObject == gameObject)
|
|
{
|
|
for (int i = 0; i < GameManager.Inst.Cabinets_go.Count; i++)
|
|
{
|
|
if (GameManager.Inst.Cabinets_go[i].activeSelf /*&&GameManager.Inst.Cabinets_go[i] != GameManager.Inst.FindParent(gameObject, GameManager.Inst.IsDesiredParent)*/)
|
|
{
|
|
GameManager.Inst.Cabinets_go[i].GetComponent<TransparentGlow>().F1();
|
|
}
|
|
}
|
|
var g = GameManager.Inst.FindParent(gameObject, GameManager.Inst.IsFindRacks_go);
|
|
if (g != null)
|
|
g.GetComponent<TransparentGlow>().F2();
|
|
|
|
GameManager.Inst.nowDevice = null;
|
|
GameManager.Inst.nowDeviceID = null;
|
|
Debug.Log("点击到配置" + gameObject.name);
|
|
//PatternChoose.Inst.sb_bj_page.SetActive(false);
|
|
//PatternChoose.Inst.sb_xz_page.SetActive(false);
|
|
//PatternChoose.Inst.dk_bj_page.SetActive(false);
|
|
//PatternChoose.Inst.dk_xz_page.SetActive(false);
|
|
//PatternChoose.Inst.sb_ck_page.SetActive(false);
|
|
PatternChoose.Inst.clspup();
|
|
GameManager.Inst.now_CK_Device = null;
|
|
|
|
|
|
var p = gameObject.GetComponent<PortQuery>();
|
|
if (p)
|
|
{
|
|
MeshRenderer renderer = p.hight.GetComponent<MeshRenderer>();
|
|
|
|
Material[] materials = renderer.materials;
|
|
|
|
Material[] newMaterials = materials.Clone() as Material[];
|
|
|
|
|
|
if (string.IsNullOrEmpty(p.portList.id))
|
|
{
|
|
if (GameManager.Inst.lastDevice)
|
|
{
|
|
if (GameManager.Inst.lastDevice != gameObject && GameManager.Inst.lastDevice.GetComponent<PortQuery>())
|
|
{
|
|
|
|
MeshRenderer renderer1 = GameManager.Inst.lastDevice.GetComponent<PortQuery>().hight.GetComponent<MeshRenderer>();
|
|
|
|
Material[] materials1 = renderer1.materials;
|
|
|
|
Material[] newMaterials1 = materials1.Clone() as Material[];
|
|
|
|
newMaterials1[0] = Resources.Load<Material>("Materials/4Tou");
|
|
renderer1.materials = newMaterials;
|
|
}
|
|
//GameManager.Inst.lastDevice.GetComponent<PortQuery>().hight.GetComponent<Renderer>().materials[0] = Resources.Load<Material>("Materials/4Tou");
|
|
}
|
|
|
|
GameManager.Inst.lastDevice = gameObject;
|
|
GameManager.Inst.lastDeviceID = null;
|
|
|
|
GameManager.Inst.nowDevice = gameObject;
|
|
newMaterials[0] = Resources.Load<Material>("Materials/1Tou");
|
|
renderer.materials = newMaterials;
|
|
//p.hight.GetComponent<Renderer>().materials[0] = Resources.Load<Material>("Materials/1Tou");
|
|
|
|
//PatternChoose.Inst.transform.Find("端口类/端口新增").gameObject.SetActive(true);//√
|
|
PatternChoose.Inst.dk_xz_page.gameObject.SetActive(true);//√
|
|
}
|
|
else
|
|
{
|
|
if (GameManager.Inst.lastDevice)
|
|
{
|
|
if (GameManager.Inst.lastDevice != gameObject && GameManager.Inst.lastDevice.GetComponent<PortQuery>())
|
|
{
|
|
MeshRenderer renderer1 = GameManager.Inst.lastDevice.GetComponent<PortQuery>().hight.GetComponent<MeshRenderer>();
|
|
|
|
Material[] materials1 = renderer1.materials;
|
|
|
|
Material[] newMaterials1 = materials1.Clone() as Material[];
|
|
|
|
newMaterials1[0] = Resources.Load<Material>("Materials/4Tou");
|
|
renderer1.materials = newMaterials;
|
|
}
|
|
//GameManager.Inst.lastDevice.GetComponent<PortQuery>().hight.GetComponent<Renderer>().materials[0] = Resources.Load<Material>("Materials/4Tou");
|
|
}
|
|
|
|
GameManager.Inst.lastDevice = gameObject;
|
|
GameManager.Inst.lastDeviceID = p.portList.id;
|
|
|
|
GameManager.Inst.nowDeviceID = p.portList.id;
|
|
GameManager.Inst.nowDevice = gameObject;
|
|
newMaterials[0] = Resources.Load<Material>("Materials/1Tou");
|
|
renderer.materials = newMaterials;
|
|
//p.hight.GetComponent<Renderer>().materials[0] = Resources.Load<Material>("Materials/1Tou");
|
|
PatternChoose.Inst.dk_bj_page.gameObject.SetActive(true);//√
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if (gameObject != GameManager.Inst.nowCabine)
|
|
{
|
|
if (Physics.Raycast(ray, out hit, 100, 1 << 6 | 1 << 14))
|
|
{
|
|
if (hit.collider.gameObject.layer == 14) return;
|
|
if (hit.collider.gameObject.GetComponent<DeviceQuery>().deviceList.type == "1" &&
|
|
hit.collider.gameObject.GetComponent<TransparentGlow>().isTransparentGlow)
|
|
{
|
|
//放大
|
|
if (hit.collider.gameObject == gameObject && !My_magnifyState)
|
|
{
|
|
Change_hide(gameObject, true, true);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
#region MyRegion
|
|
////点击模型(配置)
|
|
//if (Physics.Raycast(ray, out hit, 100, 1 << 8))
|
|
//{
|
|
// if (hit.collider.gameObject == gameObject)
|
|
// {
|
|
|
|
// if (Menu.M_数字孪生_场景管理 == CabinetUIManager.Instance.current_menu)
|
|
// {
|
|
// GameManager.Inst.search_box.SetActive(false);
|
|
// var d = gameObject.GetComponent<DeviceQuery>();
|
|
// if (d)
|
|
// {
|
|
// if (string.IsNullOrEmpty(d.deviceList.id))
|
|
// {
|
|
// GameManager.Inst.nowDevice = gameObject;
|
|
|
|
|
|
// PatternChoose.Inst.transform.Find("设备类/设备新增").gameObject.SetActive(true);//√
|
|
// }
|
|
// else
|
|
// {
|
|
// GameManager.Inst.nowDeviceID = d.deviceList.id;
|
|
// GameManager.Inst.nowDevice = gameObject;
|
|
|
|
// PatternChoose.Inst.sb_bj_page.SetActive(false);.gameObject.SetActive(true);//√
|
|
// }
|
|
// }
|
|
// }
|
|
// else if (Menu.M_数字孪生_线缆连接_配置 == CabinetUIManager.Instance.current_menu)
|
|
// {
|
|
// var p = gameObject.GetComponent<PortQuery>();
|
|
// if (p)
|
|
// {
|
|
// if (string.IsNullOrEmpty(p.portList.id))
|
|
// {
|
|
// GameManager.Inst.nowDevice = gameObject;
|
|
|
|
|
|
// PatternChoose.Inst.transform.Find("端口类/端口新增").gameObject.SetActive(true);//√
|
|
// }
|
|
// else
|
|
// {
|
|
// GameManager.Inst.nowDeviceID = p.portList.id;
|
|
// GameManager.Inst.nowDevice = gameObject;
|
|
|
|
// PatternChoose.Inst.transform.Find("端口类/端口配置").gameObject.SetActive(true);//√
|
|
// }
|
|
// }
|
|
// }
|
|
// else
|
|
// {
|
|
// PatternChoose.Inst.sb_bj_page.SetActive(false);.gameObject.SetActive(false);
|
|
// PatternChoose.Inst.dk_bj_page.SetActive(false);
|
|
// }
|
|
// }
|
|
//}
|
|
#endregion
|
|
|
|
|
|
|
|
//不虚化
|
|
else if (!GameManager.Inst.magnifyState && Physics.Raycast(ray, out hit, 100, 1 << 6 | 1 << 14 | 1 << 15 /*| 1 << 8*/| 1 << 17))//机柜-6 门-14 蓄电池-15
|
|
{
|
|
if (hit.collider.gameObject.layer == 17) return;
|
|
//放大
|
|
if (hit.collider.gameObject == gameObject && !My_magnifyState /*&& gameObject.layer != 8*/)
|
|
{
|
|
PatternChoose.Inst.sb_ck_page.SetActive(false);
|
|
GameManager.Inst.now_CK_Device = null;
|
|
Change_hide(gameObject, true, true);
|
|
}
|
|
////缩小
|
|
//else if (hit.collider.gameObject == gameObject && My_magnifyState && gameObject.layer == 8)
|
|
//{
|
|
// var d = gameObject.GetComponent<DeviceQuery>();
|
|
// if (d)
|
|
// {
|
|
// GameManager.Inst.now_CK_Device = gameObject;
|
|
// Change_hide(gameObject, false, false);
|
|
// }
|
|
|
|
//}
|
|
}
|
|
else if (GameManager.Inst.magnifyState && Physics.Raycast(ray, out hit, 100, 1 << 6 | 1 << 14 | 1 << 15 /*| 1 << 8*/| 1 << 17))//机柜-6 门-14 蓄电池-15
|
|
{
|
|
if (hit.collider.gameObject.layer == 17) return;
|
|
//放大
|
|
if (GameManager.Inst.FindParent(hit.collider.gameObject, GameManager.Inst.IsDesiredParent) != GameManager.Inst.nowCabine || hit.collider.gameObject.layer == 15)
|
|
{
|
|
if (!My_magnifyState && (hit.collider.gameObject == gameObject || (hit.collider.gameObject.layer == 14 && hit.collider.transform.parent.gameObject == gameObject)))
|
|
{
|
|
PatternChoose.Inst.sb_ck_page.SetActive(false);
|
|
GameManager.Inst.now_CK_Device = null;
|
|
Change_hide(gameObject, true, true);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
#region 虚化非点击
|
|
////虚化非点击
|
|
//else if (Physics.Raycast(ray, out hit, 100, 1 << 6))
|
|
//{
|
|
// //点到,本身透明,场景透明模式
|
|
// if (hit.collider.gameObject == gameObject && isTransparentGlow && TransparentGlowManage.Inst.is_transparency)
|
|
// {
|
|
// ChangeBig_TouMing();
|
|
// }
|
|
// //点到,本身非透明,场景透明模式
|
|
// else if (hit.collider.gameObject == gameObject && !isTransparentGlow && TransparentGlowManage.Inst.is_transparency)
|
|
// {
|
|
// ChangeSmall_renewALL();
|
|
// }
|
|
|
|
|
|
|
|
// //点到,本身非透明,场景非透明模式
|
|
// else if (hit.collider.gameObject == gameObject && !isTransparentGlow && !TransparentGlowManage.Inst.is_transparency)
|
|
// {
|
|
// ChangeBig_();
|
|
// }
|
|
//}
|
|
#endregion
|
|
}
|
|
}
|
|
private void OnMouseEnter()
|
|
{
|
|
if (!CabinetUIManager.Instance)
|
|
return;
|
|
if (CabinetUIManager.Instance.current_menu == Menu.M_数字孪生_机柜容量)
|
|
{
|
|
DeviceQuery d = null;
|
|
try
|
|
{
|
|
d = GetComponent<DeviceQuery>();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return;
|
|
}
|
|
if (d)
|
|
{
|
|
if (d.deviceList.type == "1")
|
|
{
|
|
VolumeImg v = null;
|
|
try
|
|
{
|
|
v = transform.Find("容量/Canvas").GetComponent<VolumeImg>();
|
|
}
|
|
catch
|
|
{
|
|
return;
|
|
}
|
|
if (!v) return;
|
|
v.Image.gameObject.SetActive(true);
|
|
v.textMeshProUGUI.text = "剩余" + d.deviceList.residueNum + "个U位置";
|
|
}
|
|
else return;
|
|
}
|
|
else return;
|
|
}
|
|
else if (CabinetUIManager.Instance.current_menu == Menu.M_数字孪生_智能巡检)
|
|
{
|
|
var d = GetComponent<DeviceQuery>();
|
|
if (d.deviceList.type == "1")
|
|
{
|
|
if (EventSystem.current.IsPointerOverGameObject()) return;
|
|
var digital = transform.Find("智能巡检").GetComponent<DigitalTwinPanel>();
|
|
digital.ShowUI();
|
|
}
|
|
}
|
|
}
|
|
|
|
private void OnMouseExit()
|
|
{
|
|
if (!CabinetUIManager.Instance)
|
|
return;
|
|
if (CabinetUIManager.Instance.current_menu == Menu.M_数字孪生_机柜容量)
|
|
{
|
|
DeviceQuery d = null;
|
|
try
|
|
{
|
|
d = GetComponent<DeviceQuery>();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return;
|
|
}
|
|
if (d)
|
|
{
|
|
if (d.deviceList.type == "1")
|
|
{
|
|
VolumeImg v = null;
|
|
try
|
|
{
|
|
v = transform.Find("容量/Canvas").GetComponent<VolumeImg>();
|
|
}
|
|
catch
|
|
{
|
|
return;
|
|
}
|
|
if (!v) return;
|
|
v.Image.gameObject.SetActive(false);
|
|
}
|
|
else return;
|
|
}
|
|
else return;
|
|
}
|
|
else if (CabinetUIManager.Instance.current_menu == Menu.M_数字孪生_智能巡检)
|
|
{
|
|
var d = GetComponent<DeviceQuery>();
|
|
if (d.deviceList.type == "1")
|
|
{
|
|
var digital = transform.Find("智能巡检").GetComponent<DigitalTwinPanel>();
|
|
digital.HideUI();
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 本身透明
|
|
/// </summary>
|
|
[ContextMenu("透明")]
|
|
public void F1()
|
|
{
|
|
isTransparentGlow = true;
|
|
//for (int i = 0; i < Materials.Count; i++)
|
|
//{
|
|
// Materials[i].shader = TransparentGlow_Shader;
|
|
//}
|
|
if (GetComponent<TransparentGlow>())
|
|
GetComponent<TransparentGlow>().F1();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 本身恢复原材质
|
|
/// </summary>
|
|
[ContextMenu("恢复原材质")]
|
|
public void F2()
|
|
{
|
|
isTransparentGlow = false;
|
|
//for (int i = 0; i < Materials.Count; i++)
|
|
//{
|
|
// Materials[i].shader = empty[i].shader;
|
|
//}
|
|
if (GetComponent<TransparentGlow>())
|
|
GetComponent<TransparentGlow>().F2();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 变大=>场景透明,自身不变
|
|
/// </summary>
|
|
public void ChangeBig_TouMing()
|
|
{
|
|
ExtendedFlycam.Inst.init_mainCamera_rot();
|
|
isTransparentGlow = true;
|
|
// 物体被点击
|
|
Debug.Log("放大点击到" + gameObject.name);
|
|
//Renderer renderer = GetComponent<Renderer>();
|
|
Renderer renderer = null;
|
|
//if (transform.childCount != 0)
|
|
// renderer = transform.Find(transform.name).GetComponent<Renderer>();
|
|
//else
|
|
// renderer = transform.GetComponent<Renderer>();
|
|
try
|
|
{
|
|
renderer = transform.Find(transform.name).GetComponent<Renderer>();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
if (!renderer) renderer = transform.GetComponentInChildren<Renderer>();
|
|
}
|
|
|
|
Vector3 center = renderer.bounds.center;
|
|
Vector3 targetPosition = new Vector3(center.x + yiDong_pos.x, center.y + yiDong_pos.y, center.z + yiDong_pos.z);
|
|
Quaternion targetRotation = Quaternion.Euler(fangDa_rot);
|
|
Camera.main.transform.DOMove(targetPosition, 1f);
|
|
Camera.main.transform.DORotateQuaternion(targetRotation, 1f).OnComplete(() =>
|
|
{
|
|
//更新相机初始旋转角度
|
|
ExtendedFlycam.Inst.initialRotationEulerAngles = Camera.main.transform.localEulerAngles;
|
|
});
|
|
|
|
|
|
TransparentGlowManage.Inst.transparencyALL();
|
|
F2();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 变小=>场景恢复
|
|
/// </summary>
|
|
public void ChangeSmall_renewALL()
|
|
{
|
|
ExtendedFlycam.Inst.init_mainCamera_rot();
|
|
isTransparentGlow = false;
|
|
// 物体被点击
|
|
Debug.Log("缩小点击到" + gameObject.name);
|
|
Camera.main.transform.DOMove(TransparentGlowManage.Inst.MainCamera_pos, 1f);
|
|
Camera.main.transform.DORotateQuaternion(Quaternion.Euler(TransparentGlowManage.Inst.MainCamera_rot), 1f).OnComplete(() =>
|
|
{
|
|
//更新相机初始旋转角度
|
|
ExtendedFlycam.Inst.initialRotationEulerAngles = Camera.main.transform.localEulerAngles;
|
|
});
|
|
|
|
|
|
TransparentGlowManage.Inst.renewALL();
|
|
}
|
|
|
|
public void ChangeBig_()
|
|
{
|
|
ExtendedFlycam.Inst.init_mainCamera_rot();
|
|
isTransparentGlow = true;
|
|
// 物体被点击
|
|
Debug.Log("放大点击到" + gameObject.name);
|
|
//Renderer renderer = GetComponent<Renderer>();
|
|
Renderer renderer = null;
|
|
//if (transform.childCount != 0)
|
|
// renderer = transform.Find(transform.name).GetComponent<Renderer>();
|
|
//else
|
|
// renderer = transform.GetComponent<Renderer>();
|
|
try
|
|
{
|
|
renderer = transform.Find(transform.name).GetComponent<Renderer>();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
if (!renderer) renderer = transform.GetComponentInChildren<Renderer>();
|
|
}
|
|
Vector3 center = renderer.bounds.center;
|
|
Vector3 targetPosition = new Vector3(center.x + yiDong_pos.x, center.y + yiDong_pos.y, center.z + yiDong_pos.z); Quaternion targetRotation = Quaternion.Euler(fangDa_rot);
|
|
Camera.main.transform.DOMove(targetPosition, 1f);
|
|
Camera.main.transform.DORotateQuaternion(targetRotation, 1f).OnComplete(() =>
|
|
{
|
|
//更新相机初始旋转角度
|
|
ExtendedFlycam.Inst.initialRotationEulerAngles = Camera.main.transform.localEulerAngles;
|
|
});
|
|
|
|
|
|
TransparentGlowManage.Inst.transparencyALL();
|
|
F2();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 机柜隐藏+是否拉近镜头
|
|
/// </summary>
|
|
/// <param name="isHide">机柜隐藏</param>
|
|
/// <param name="isZoomin">是否拉近镜头</param>
|
|
public void Change_hide(GameObject cabine, bool isHide, bool isZoomin, bool setNowCabine = true)
|
|
{
|
|
//GameManager.Inst.nowCabine = cabine;
|
|
if (cabine.layer != 15)
|
|
//cabine = GameManager.Inst.nowCabine;
|
|
cabine = GameManager.Inst.FindParent(cabine, GameManager.Inst.IsDesiredParent);
|
|
if (setNowCabine)
|
|
GameManager.Inst.nowCabine = cabine;
|
|
//放大
|
|
if (isZoomin)
|
|
Zoomin(cabine);
|
|
//缩小
|
|
else
|
|
//Zoomout(cabine);
|
|
Device_popup(cabine);
|
|
if (isZoomin)
|
|
{
|
|
if (CabinetUIManager.Instance.cabine_hights_now.Count == 0)
|
|
{
|
|
for (int i = 0; i < CabinetUIManager.Instance.cabine_hights.Count; i++)
|
|
{
|
|
if (CabinetUIManager.Instance.cabine_hights[i].activeSelf)
|
|
{
|
|
CabinetUIManager.Instance.cabine_hights[i].SetActive(false);
|
|
CabinetUIManager.Instance.cabine_hights_now.Add(CabinetUIManager.Instance.cabine_hights[i]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//else
|
|
//{
|
|
// for (int i = 0; i < CabinetUIManager.Instance.cabine_hights_now.Count; i++)
|
|
// {
|
|
// CabinetUIManager.Instance.cabine_hights_now[i].SetActive(true);
|
|
// }
|
|
// CabinetUIManager.Instance.cabine_hights_now.Clear();
|
|
//}
|
|
|
|
if (gameObject.layer == 15) return;
|
|
string s1 = gameObject.GetComponent<DeviceQuery>().deviceList.devicePosition.Split('-')[0];
|
|
|
|
if (Menu.M_数字孪生_线缆连接_展示 == CabinetUIManager.Instance.current_menu)
|
|
{
|
|
|
|
}
|
|
else if (Menu.M_全景监控_现场作业 == CabinetUIManager.Instance.current_menu)
|
|
{
|
|
WebInteraction.Inst.CloseVideo("All");
|
|
//string p = cabine.GetComponent<DeviceQuery>().deviceList.devicePosition.Split("-")[0].ToUpper();
|
|
//WebInteraction.Inst.OpenVideo("摄像头编号");
|
|
//switch (p)
|
|
//{
|
|
// case "A":
|
|
// {
|
|
// WebInteraction.Inst.OpenVideo("09");
|
|
// break;
|
|
// }
|
|
// case "B":
|
|
// {
|
|
// WebInteraction.Inst.OpenVideo("08");
|
|
// break;
|
|
// }
|
|
// case "C":
|
|
// {
|
|
// WebInteraction.Inst.OpenVideo("07");
|
|
// break;
|
|
// }
|
|
// case "D":
|
|
// {
|
|
// WebInteraction.Inst.OpenVideo("06");
|
|
// break;
|
|
// }
|
|
// case "E":
|
|
// {
|
|
// WebInteraction.Inst.OpenVideo("05");
|
|
// break;
|
|
// }
|
|
// case "F":
|
|
// {
|
|
// WebInteraction.Inst.OpenVideo("04");
|
|
// break;
|
|
// }
|
|
// case "G":
|
|
// {
|
|
// WebInteraction.Inst.OpenVideo("03");
|
|
// break;
|
|
// }
|
|
// case "H":
|
|
// {
|
|
// WebInteraction.Inst.OpenVideo("02");
|
|
// break;
|
|
// }
|
|
// case "I":
|
|
// {
|
|
// WebInteraction.Inst.OpenVideo("01");
|
|
// break;
|
|
// }
|
|
// default:
|
|
// break;
|
|
//}
|
|
FindVideo(cabine);
|
|
}
|
|
if (Menu.M_数字孪生_接地网 != CabinetUIManager.Instance.current_menu)
|
|
{
|
|
if (isHide)
|
|
{
|
|
for (int i = 0; i < GameManager.Inst.Cabinets_go.Count; i++)
|
|
{
|
|
string s2 = GameManager.Inst.Cabinets_go[i].GetComponent<DeviceQuery>().deviceList.devicePosition.Split('-')[0];
|
|
if (s1 != s2)
|
|
{
|
|
GameManager.Inst.Cabinets_go[i].SetActive(!isHide);
|
|
}
|
|
else if (s1 == s2 && GameManager.Inst.Cabinets_go[i] != gameObject)
|
|
{
|
|
GameManager.Inst.Cabinets_go[i].GetComponent<TransparentGlow>().F1();
|
|
GameManager.Inst.Cabinets_go[i].SetActive(true);
|
|
}
|
|
//Array.ForEach(GameManager.Inst.Cabinets_go[i].GetComponentsInChildren<RoomDoor>(true), (itme) =>
|
|
//{
|
|
// itme.gameObject.GetComponent<BoxCollider>().enabled = false;
|
|
//});
|
|
}
|
|
//Array.ForEach(gameObject.GetComponentsInChildren<RoomDoor>(true), (itme) =>
|
|
//{
|
|
// itme.gameObject.GetComponent<BoxCollider>().enabled = true;
|
|
//});
|
|
gameObject.SetActive(true);
|
|
gameObject.GetComponent<TransparentGlow>().F2();
|
|
}
|
|
//else
|
|
//{
|
|
// for (int i = 0; i < GameManager.Inst.Cabinets_go.Count; i++)
|
|
// {
|
|
// string s2 = GameManager.Inst.Cabinets_go[i].GetComponent<DeviceQuery>().deviceList.devicePosition.Split('-')[0];
|
|
// if (s1 != s2)
|
|
// GameManager.Inst.Cabinets_go[i].SetActive(!isHide);
|
|
// else if (s1 == s2 && GameManager.Inst.Cabinets_go[i] != gameObject)
|
|
// GameManager.Inst.Cabinets_go[i].GetComponent<TransparentGlow>().F2();
|
|
// }
|
|
// for (int i = 0; i < GameManager.Inst.roomDoors.Count; i++)
|
|
// {
|
|
// GameManager.Inst.roomDoors[i].gameObject.GetComponent<BoxCollider>().enabled = true;
|
|
// }
|
|
//}
|
|
}
|
|
|
|
|
|
if (Menu.M_全景监控_柜门状态 != CabinetUIManager.Instance.current_menu)
|
|
{
|
|
#region old
|
|
//if (isZoomin)
|
|
//{
|
|
// for (int i = 0; i < GameManager.Inst.Cabinets_go.Count; i++)
|
|
// {
|
|
// if (cabine == GameManager.Inst.Cabinets_go[i])
|
|
// {
|
|
// if (cabine.transform.Find("门把手") == null || GameManager.Inst.Cabinets_go[i].transform.Find("门把手") == null)
|
|
// continue;
|
|
// var door = cabine.transform.Find("门把手").GetComponentInChildren<Door>(true);
|
|
|
|
// GameManager.Inst.power_open(cabine, "全开");
|
|
// //door.TextMeshProUGUI.text = "关门";
|
|
// door.isopen = !door.isopen;
|
|
// }
|
|
// else if (cabine && cabine != GameManager.Inst.Cabinets_go[i])
|
|
// {
|
|
// if (GameManager.Inst.Cabinets_go[i].transform.Find("门把手") == null ||
|
|
// !GameManager.Inst.Cabinets_go[i].activeSelf)
|
|
// continue;
|
|
// var door = GameManager.Inst.Cabinets_go[i].transform.Find("门把手").GetComponentInChildren<Door>(true);
|
|
|
|
|
|
// GameManager.Inst.power_close(GameManager.Inst.Cabinets_go[i], "全关");
|
|
// //door.TextMeshProUGUI.text = "开门";
|
|
// door.isopen = !door.isopen;
|
|
// }
|
|
|
|
// }
|
|
// for (int i = 0; i < GameManager.Inst.Racks_go.Count; i++)
|
|
// {
|
|
// if (!GameManager.Inst.Racks_go[i].activeSelf)
|
|
// continue;
|
|
// if (GameManager.Inst.Racks_go[i].GetComponent<DeviceQuery>().deviceList.modelNum == "6" ||
|
|
// GameManager.Inst.Racks_go[i].GetComponent<DeviceQuery>().deviceList.modelNum == "7")
|
|
// GameManager.Inst.Racks_go[i].transform.Find("前盖").gameObject.SetActive(false);
|
|
// }
|
|
//}
|
|
//else
|
|
//{
|
|
// if (cabine && cabine == gameObject && cabine.transform.Find("门把手"))
|
|
// {
|
|
// var door = cabine.transform.Find("门把手").GetComponentInChildren<Door>(true);
|
|
// //if (door.TextMeshProUGUI.text == "开门") return;
|
|
// GameManager.Inst.power_close(cabine, "全关");
|
|
// //door.TextMeshProUGUI.text = "开门";
|
|
// door.isopen = !door.isopen;
|
|
// }
|
|
// for (int i = 0; i < GameManager.Inst.Racks_go.Count; i++)
|
|
// {
|
|
// if (GameManager.Inst.Racks_go[i].GetComponent<DeviceQuery>().deviceList.modelNum == "6" ||
|
|
// GameManager.Inst.Racks_go[i].GetComponent<DeviceQuery>().deviceList.modelNum == "7")
|
|
// GameManager.Inst.Racks_go[i].transform.Find("前盖").gameObject.SetActive(true);
|
|
// }
|
|
//}
|
|
#endregion
|
|
if (isZoomin)
|
|
{
|
|
GameManager.Inst.power_close();
|
|
GameManager.Inst.power_open(cabine, "全开");
|
|
openCap(isZoomin);
|
|
}
|
|
//openCap(isZoomin);
|
|
//else
|
|
//{
|
|
// GameManager.Inst.power_close();
|
|
// openCap(isZoomin);
|
|
//}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 模型微调(打开前盖)
|
|
/// </summary>
|
|
/// <param name="isZoomin">是否为放大状态</param>
|
|
public void openCap(bool isZoomin)
|
|
{
|
|
for (int i = 0; i < GameManager.Inst.Racks_go.Count; i++)
|
|
{
|
|
if (!GameManager.Inst.Racks_go[i].activeSelf)
|
|
continue;
|
|
if (GameManager.Inst.Racks_go[i].GetComponent<DeviceQuery>().deviceList.modelNum == "6" ||
|
|
GameManager.Inst.Racks_go[i].GetComponent<DeviceQuery>().deviceList.modelNum == "7" ||
|
|
GameManager.Inst.Racks_go[i].GetComponent<DeviceQuery>().deviceList.modelNum == "20" ||
|
|
GameManager.Inst.Racks_go[i].GetComponent<DeviceQuery>().deviceList.modelNum == "21" ||
|
|
GameManager.Inst.Racks_go[i].GetComponent<DeviceQuery>().deviceList.modelNum == "91" ||
|
|
GameManager.Inst.Racks_go[i].GetComponent<DeviceQuery>().deviceList.modelNum == "92" ||
|
|
GameManager.Inst.Racks_go[i].GetComponent<DeviceQuery>().deviceList.modelNum == "93")
|
|
GameManager.Inst.Racks_go[i].transform.Find("前盖").gameObject.SetActive(!isZoomin);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 放大镜头
|
|
/// </summary>
|
|
public void Zoomin(GameObject cabine)
|
|
{
|
|
if (CabinetUIManager.Instance.current_menu == Menu.M_数字孪生_场景管理)
|
|
GameManager.Inst.search_box.SetActive(false);
|
|
ExtendedFlycam.Inst.CameraRtDisable();
|
|
ExtendedFlycam.Inst.QieHuan(CabinetUIManager.Instance.current_menu, 99);
|
|
|
|
//GameManager.Inst.magnifyState = true;
|
|
TransparentGlowManage.Inst.is_magnify = true;
|
|
|
|
if (cabine.layer != 15)
|
|
{
|
|
if (Menu.M_数字孪生_线缆连接_配置 == CabinetUIManager.Instance.current_menu)
|
|
{
|
|
Array.ForEach(cabine.GetComponentsInChildren<PortQuery>(), (itme) =>
|
|
{
|
|
Renderer renderer = itme.transform.GetChild(0).GetComponent<Renderer>();
|
|
|
|
Material[] sharedMaterials = renderer.sharedMaterials;
|
|
|
|
sharedMaterials[0] = Resources.Load<Material>("Materials/4Tou"); ;
|
|
|
|
renderer.sharedMaterials = sharedMaterials;
|
|
itme.hight.SetActive(true);
|
|
});
|
|
}
|
|
else if (Menu.M_数字孪生_场景管理 == CabinetUIManager.Instance.current_menu)
|
|
{
|
|
if (!GameManager.Inst.objectToShow_add.activeSelf)
|
|
{
|
|
GameManager.Inst.objectToShow_add.SetActive(true);
|
|
}
|
|
|
|
}
|
|
if (Menu.M_数字孪生_线缆连接_配置 != CabinetUIManager.Instance.current_menu)
|
|
{
|
|
Array.ForEach(cabine.GetComponentsInChildren<PortQuery>(), (itme) =>
|
|
{
|
|
itme.hight.SetActive(false);
|
|
});
|
|
}
|
|
|
|
if (cabine.transform.Find("U位"))
|
|
GameManager.Inst.gameObject.GetComponent<DeviceManager>().dragController.uPosManger = cabine.transform.Find("U位").GetComponent<UPosManger>();
|
|
|
|
if (Menu.M_全景监控_现场作业 == CabinetUIManager.Instance.current_menu)
|
|
{
|
|
WebInteraction.Inst.CloseVideo("All");
|
|
FindVideo(cabine);
|
|
}
|
|
}
|
|
if (Menu.M_全景监控_摄像头 == CabinetUIManager.Instance.current_menu)
|
|
{
|
|
if (cabine.name.Contains("蓄电池"))
|
|
{
|
|
for (int i = 0; i < ExtendedFlycam.Inst.peiDianShi.Count; i++)
|
|
{
|
|
ExtendedFlycam.Inst.peiDianShi[i].SetActive(true);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (selected_cabient != null)
|
|
{
|
|
CameraMgr.Instance.camera_Rt.KillCameraDotween();
|
|
}
|
|
if (selected_cabient == null)
|
|
{
|
|
CameraMgr.Instance.StoreTarget();
|
|
selected_cabient = cabine.transform;
|
|
}
|
|
//ExtendedFlycam.Inst.init_mainCamera_rot();
|
|
// 物体被点击
|
|
Debug.Log("放大点击到" + gameObject.name);
|
|
if (GetComponent<DeviceQuery>())
|
|
{
|
|
GameManager.Inst.nowDevice = gameObject;
|
|
GameManager.Inst.nowDeviceID = GetComponent<DeviceQuery>().deviceList.id;
|
|
}
|
|
else if (gameObject.layer == 15)
|
|
{
|
|
}
|
|
else return;
|
|
Renderer renderer = null;
|
|
try
|
|
{
|
|
renderer = transform.Find(transform.name).GetComponent<Renderer>();
|
|
|
|
}
|
|
catch (Exception)
|
|
{
|
|
if (!renderer) renderer = transform.GetComponentInChildren<Renderer>();
|
|
|
|
}
|
|
Array.ForEach(GameObject.FindObjectsOfType<ClickEvent>(), itme =>
|
|
{
|
|
itme.My_magnifyState = false;
|
|
});
|
|
My_magnifyState = true;
|
|
|
|
Vector3 center = renderer.bounds.center;
|
|
//Vector3 targetPosition = new Vector3(center.x + yiDong_pos.x, center.y + yiDong_pos.y, center.z + yiDong_pos.z);
|
|
Vector3 targetPosition = new Vector3(center.x, center.y, center.z) + yiDong_pos;
|
|
|
|
Quaternion targetRotation = Quaternion.Euler(fangDa_rot);
|
|
Camera.main.transform.DOMove(targetPosition, 1f);
|
|
Camera.main.transform.DORotateQuaternion(targetRotation, 1f).OnComplete(() =>
|
|
{
|
|
//更新相机初始旋转角度
|
|
//ExtendedFlycam.Inst.initialRotationEulerAngles = Camera.main.transform.localEulerAngles;
|
|
|
|
//镜头微调
|
|
if (gameObject.name == "R69" || gameObject.name == "R70")
|
|
CameraMgr.Instance.GotoView(cabine.transform, 2, targetRotation, 0);
|
|
else if (cabine.layer != 15)
|
|
{
|
|
var nub = int.Parse(cabine.name.Replace("R", ""));
|
|
if ((nub >= 5 && nub <= 7) ||
|
|
(nub >= 10 && nub <= 12) ||
|
|
(nub >= 26 && nub <= 32) ||
|
|
(nub >= 40 && nub <= 64) ||
|
|
(nub >= 69 && nub <= 70) ||
|
|
nub == 15)
|
|
CameraMgr.Instance.GotoView(cabine.transform, 2, targetRotation, 2);
|
|
else
|
|
CameraMgr.Instance.GotoView(cabine.transform, 2, targetRotation, 1);
|
|
}
|
|
else
|
|
CameraMgr.Instance.GotoView(cabine.transform.parent, 2, targetRotation, 3);
|
|
|
|
ExtendedFlycam.Inst.CameraRtEnable();
|
|
GameManager.Inst.magnifyState = true;
|
|
});
|
|
}
|
|
|
|
/// <summary>
|
|
/// 缩小镜头
|
|
/// </summary>
|
|
/// <param name="hit"></param>
|
|
public void Zoomout(GameObject cabine)
|
|
{
|
|
ExtendedFlycam.Inst.CameraRtDisable();
|
|
|
|
GameManager.Inst.magnifyState = false;
|
|
TransparentGlowManage.Inst.is_magnify = false;
|
|
|
|
Array.ForEach(cabine.GetComponentsInChildren<PortQuery>(), (itme) =>
|
|
{
|
|
itme.hight.SetActive(false);
|
|
});
|
|
|
|
|
|
GameManager.Inst.nowDeviceID = null;
|
|
My_magnifyState = false;
|
|
|
|
//ExtendedFlycam.Inst.init_mainCamera_rot();
|
|
// 物体被点击
|
|
Debug.Log("缩小点击到" + gameObject.name);
|
|
//Camera.main.transform.DOMove(TransparentGlowManage.Inst.MainCamera_pos, 1f);
|
|
//Camera.main.transform.DORotateQuaternion(Quaternion.Euler(TransparentGlowManage.Inst.MainCamera_rot), 1f).OnComplete(() =>
|
|
//{
|
|
// //更新相机初始旋转角度
|
|
// //ExtendedFlycam.Inst.initialRotationEulerAngles = Camera.main.transform.localEulerAngles;
|
|
// CameraMgr.Instance.ResumeView();
|
|
// selected_cabient = null;
|
|
// ExtendedFlycam.Inst.CameraRtEnable();
|
|
//});
|
|
|
|
|
|
GameManager.Inst.editorMenu.gameObject.SetActive(false);
|
|
ExtendedFlycam.Inst.QieHuan(CabinetUIManager.Instance.current_menu);
|
|
CameraMgr.Instance.ResumeView();
|
|
selected_cabient = null;
|
|
ExtendedFlycam.Inst.CameraRtEnable();
|
|
for (int i = 0; i < PatternChoose.Inst.xianlan.transform.childCount; i++)
|
|
{
|
|
PatternChoose.Inst.xianlan.transform.GetChild(i).gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 展示设备信息
|
|
/// </summary>
|
|
public void Device_popup(GameObject cabine)
|
|
{
|
|
var _cabine = GameManager.Inst.FindParent(cabine, GameManager.Inst.IsDesiredParent);
|
|
if (!_cabine || GameManager.Inst.nowCabine != _cabine)
|
|
return;
|
|
PatternChoose.Inst.sb_xz_page.SetActive(false);
|
|
PatternChoose.Inst.sb_bj_page.SetActive(false);
|
|
PatternChoose.Inst.dk_bj_page.SetActive(false);
|
|
PatternChoose.Inst.dk_xz_page.SetActive(false);
|
|
GameManager.Inst.checkDevice();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据机柜打开摄像机
|
|
/// </summary>
|
|
/// <param name="cabine"></param>
|
|
public void FindVideo(GameObject cabine)
|
|
{
|
|
string l = cabine.GetComponent<DeviceQuery>().deviceList.devicePosition.Split("-")[0].ToUpper();
|
|
switch (l)
|
|
{
|
|
case "A":
|
|
{
|
|
WebInteraction.Inst.isVideoPlay = true;
|
|
WebInteraction.Inst.OpenVideo("09");
|
|
break;
|
|
}
|
|
case "B":
|
|
{
|
|
WebInteraction.Inst.isVideoPlay = true;
|
|
WebInteraction.Inst.OpenVideo("08");
|
|
break;
|
|
}
|
|
case "C":
|
|
{
|
|
WebInteraction.Inst.isVideoPlay = true;
|
|
WebInteraction.Inst.OpenVideo("07");
|
|
break;
|
|
}
|
|
case "D":
|
|
{
|
|
WebInteraction.Inst.isVideoPlay = true;
|
|
WebInteraction.Inst.OpenVideo("06");
|
|
break;
|
|
}
|
|
case "E":
|
|
{
|
|
WebInteraction.Inst.isVideoPlay = true;
|
|
WebInteraction.Inst.OpenVideo("05");
|
|
break;
|
|
}
|
|
case "F":
|
|
{
|
|
WebInteraction.Inst.isVideoPlay = true;
|
|
WebInteraction.Inst.OpenVideo("04");
|
|
break;
|
|
}
|
|
case "G":
|
|
{
|
|
WebInteraction.Inst.isVideoPlay = true;
|
|
WebInteraction.Inst.OpenVideo("03");
|
|
break;
|
|
}
|
|
case "H":
|
|
{
|
|
WebInteraction.Inst.isVideoPlay = true;
|
|
WebInteraction.Inst.OpenVideo("02");
|
|
break;
|
|
}
|
|
case "I":
|
|
{
|
|
WebInteraction.Inst.isVideoPlay = true;
|
|
WebInteraction.Inst.OpenVideo("01");
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 插入设备动画
|
|
/// </summary>
|
|
public void insertion(Transform t, Vector3 endPos, bool isLocal = true)
|
|
{
|
|
Collider collider = t.GetComponent<Collider>();
|
|
Bounds modelBounds = collider.bounds;
|
|
Vector3 modelSize = modelBounds.size;
|
|
float modelWidth = modelSize.x;
|
|
float modelHeight = modelSize.y;
|
|
float modelDepth = modelSize.z;
|
|
//endPos = t.localPosition = new Vector3((float)modelWidth / 2, 0, 0);
|
|
Debug.Log("################\n" + "modelWidth: " + modelWidth + "\nmodelHeight: " + modelHeight + "\nmodelDepth: " + modelDepth);
|
|
|
|
if (isLocal)
|
|
{
|
|
t.DOLocalMove(endPos, 1);
|
|
}
|
|
else
|
|
{
|
|
t.DOMove(endPos, 1);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 拔出设备动画
|
|
/// </summary>
|
|
public void insert(Transform t, Vector3 endPos, bool isLocal = true)
|
|
{
|
|
Collider collider = t.GetComponent<Collider>();
|
|
Bounds modelBounds = collider.bounds;
|
|
Vector3 modelSize = modelBounds.size;
|
|
float modelWidth = modelSize.x;
|
|
float modelHeight = modelSize.y;
|
|
float modelDepth = modelSize.z;
|
|
//endPos = t.localPosition = new Vector3((float)modelWidth / 2, 0, 0);
|
|
Debug.Log("################\n" + "modelWidth: " + modelWidth + "\nmodelHeight: " + modelHeight + "\nmodelDepth: " + modelDepth);
|
|
|
|
if (isLocal)
|
|
{
|
|
endPos = t.localPosition = new Vector3((float)modelWidth / 2, 0, 0);
|
|
t.DOLocalMove(endPos, 1);
|
|
}
|
|
else
|
|
{
|
|
t.DOMove(endPos, 1);
|
|
}
|
|
}
|
|
} |