500 lines
23 KiB
C#
500 lines
23 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using static WebInteraction;
|
|
|
|
public class UIToCabinet : MonoBehaviour
|
|
{
|
|
public List<Toggle> toggles = new List<Toggle>();
|
|
|
|
/// <summary>
|
|
/// 机柜容量标识
|
|
/// </summary>
|
|
public GameObject rongLaing;
|
|
|
|
public GameObject xianlanpz;
|
|
|
|
public GameObject mask_img;
|
|
|
|
public Button enter_home;
|
|
public Button back_home;
|
|
|
|
public GameObject first_level_menu;
|
|
public List<GameObject> second_level_menu;
|
|
|
|
public List<ClickEventLens> clickEventLens = new List<ClickEventLens>();
|
|
|
|
public Transform Stagin;
|
|
private void Awake()
|
|
{
|
|
clickEventLens = GameObject.FindObjectsOfType<ClickEventLens>().ToList();
|
|
}
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
enter_home.onClick.AddListener(() =>
|
|
{
|
|
mask_img.SetActive(false);
|
|
first_level_menu.SetActive(true);
|
|
});
|
|
toggles = GetComponentsInChildren<Toggle>(true).ToList();
|
|
back_home.onClick.AddListener(() =>
|
|
{
|
|
if (mask_img.activeSelf)
|
|
return;
|
|
mask_img.SetActive(true);
|
|
|
|
TransparentGlowManage.Inst.renewALL();
|
|
|
|
CabinetUIManager.ChangeMenu(Menu.None);
|
|
first_level_menu.transform.Find("Toggle Group/Toggle_全景监控").GetComponent<Toggle>().isOn = true;
|
|
|
|
for (int i = 0; i < GameManager.Inst.Cabinets_go.Count; i++)
|
|
GameManager.Inst.Cabinets_go[i].transform.Find("高亮").gameObject.SetActive(false);
|
|
|
|
for (int i = 0; i < second_level_menu.Count; i++)
|
|
second_level_menu[i].SetActive(false);
|
|
for (int i = 0; i < GameManager.Inst.pop_ups.Count; i++)
|
|
GameManager.Inst.pop_ups[i].SetActive(false);
|
|
first_level_menu.SetActive(false);
|
|
|
|
});
|
|
for (int i = 0; i < toggles.Count; i++)
|
|
{
|
|
var index = i;
|
|
toggles[index].onValueChanged.AddListener((ison) =>
|
|
{
|
|
if (!toggles[index].gameObject.activeInHierarchy)
|
|
return;
|
|
if (ison)
|
|
{
|
|
bool isgo = true;
|
|
if (toggles[index].name != "Toggle_场景管理" && Stagin.childCount > 0)
|
|
{
|
|
|
|
SecondConfirmPanel.DeleteConform((delete) =>
|
|
{
|
|
if (delete)
|
|
{
|
|
var d = PatternChoose.Inst.transform.Find("设备类").GetComponent<DeleteDevice>();
|
|
for (int z = 0; z < Stagin.childCount; z++)
|
|
{
|
|
d.mybody.ids.Add(Stagin.GetChild(z).GetComponent<DeviceQuery>().deviceList.id);
|
|
}
|
|
StartCoroutine(d.SaveJsonCoroutine((x) =>
|
|
{
|
|
for (int z = Stagin.childCount - 1; z >= 0; z--)
|
|
{
|
|
DestroyImmediate(Stagin.GetChild(z).gameObject);
|
|
}
|
|
}));
|
|
}
|
|
else
|
|
{
|
|
Stagin.gameObject.SetActive(true);
|
|
isgo = false;
|
|
return;
|
|
}
|
|
}, "是否删除暂存箱子中所有设备");
|
|
|
|
}
|
|
if (!isgo|| SecondConfirmPanel.Instance.transform.GetChild(0).gameObject.activeInHierarchy)
|
|
return;
|
|
CreateLine createLine = PatternChoose.Inst.huaXian;
|
|
UI_init();
|
|
Debug.Log("第" + index);
|
|
|
|
if (mask_img.activeSelf) return;
|
|
switch (toggles[index].name)
|
|
{
|
|
case "Toggle_设备告警":
|
|
{
|
|
StartCoroutine(Loadinfo(Menu.M_全景监控_设备告警, (x) =>
|
|
{
|
|
if (string.IsNullOrEmpty(x)) return;
|
|
init(Menu.M_全景监控_设备告警);
|
|
//ExtendedFlycam.Inst.QuanJing();
|
|
PatternChoose.Inst.transform.Find("Panel搜索框").GetComponent<SearchName>().LoadCabinet(SearchName.SearchType.机柜);
|
|
GameManager.Inst.search_box.SetActive(true);
|
|
ExtendedFlycam.Inst.QieHuan(Menu.M_全景监控_设备告警);
|
|
CabinetUIManager.ChangeMenu(Menu.M_全景监控_设备告警);
|
|
}));
|
|
}
|
|
break;
|
|
case "Toggle_全景监控":
|
|
{
|
|
StartCoroutine(Loadinfo(Menu.M_全景监控_设备告警, (x) =>
|
|
{
|
|
if (string.IsNullOrEmpty(x)) return;
|
|
init(Menu.M_全景监控_设备告警);
|
|
//ExtendedFlycam.Inst.QuanJing();
|
|
GameManager.Inst.search_box.GetComponent<SearchName>().LoadCabinet(SearchName.SearchType.机柜);
|
|
GameManager.Inst.search_box.SetActive(true);
|
|
ExtendedFlycam.Inst.QieHuan(Menu.M_全景监控_设备告警);
|
|
CabinetUIManager.ChangeMenu(Menu.M_全景监控_设备告警);
|
|
}));
|
|
}
|
|
break;
|
|
case "Toggle_数字孪生":
|
|
{
|
|
rongLaing.SetActive(true);
|
|
init(Menu.M_数字孪生_机柜容量);
|
|
//ExtendedFlycam.Inst.QuanJing();
|
|
ExtendedFlycam.Inst.QieHuan(Menu.M_数字孪生_机柜容量);
|
|
GameManager.Inst.DisplayCapacity(ison);
|
|
PatternChoose.Inst.transform.Find("Panel搜索框").GetComponent<SearchName>().LoadCabinet(SearchName.SearchType.机柜);
|
|
CabinetUIManager.ChangeMenu(Menu.M_数字孪生_机柜容量);
|
|
}
|
|
break;
|
|
case "Toggle_温湿度":
|
|
{
|
|
StartCoroutine(Loadinfo(Menu.M_全景监控_温度, (x) =>
|
|
{
|
|
if (string.IsNullOrEmpty(x)) return;
|
|
init(Menu.M_全景监控_温度);
|
|
//ExtendedFlycam.Inst.QuanJing();
|
|
PatternChoose.Inst.transform.Find("Panel搜索框").GetComponent<SearchName>().LoadCabinet(SearchName.SearchType.机柜);
|
|
GameManager.Inst.search_box.SetActive(true);
|
|
ExtendedFlycam.Inst.QieHuan(Menu.M_全景监控_温度);
|
|
CabinetUIManager.ChangeMenu(Menu.M_全景监控_温度);
|
|
}));
|
|
}
|
|
break;
|
|
case "Toggle_柜门状态":
|
|
{
|
|
init(Menu.M_全景监控_柜门状态);
|
|
//ExtendedFlycam.Inst.QuanJing();
|
|
GameManager.Inst.DoorCondition(/*ison*/);
|
|
PatternChoose.Inst.transform.Find("Panel搜索框").GetComponent<SearchName>().LoadCabinet(SearchName.SearchType.机柜);
|
|
GameManager.Inst.search_box.SetActive(true);
|
|
ExtendedFlycam.Inst.QieHuan(Menu.M_全景监控_柜门状态);
|
|
CabinetUIManager.ChangeMenu(Menu.M_全景监控_柜门状态);
|
|
}
|
|
break;
|
|
case "Toggle_红外监测":
|
|
{
|
|
init(Menu.M_全景监控_红外监测);
|
|
//ExtendedFlycam.Inst.QuanJing();
|
|
GameManager.Inst.search_box.SetActive(false);
|
|
ExtendedFlycam.Inst.QieHuan(Menu.M_全景监控_红外监测);
|
|
CabinetUIManager.ChangeMenu(Menu.M_全景监控_红外监测);
|
|
}
|
|
break;
|
|
case "Toggle_现场作业":
|
|
{
|
|
init(Menu.M_全景监控_现场作业);
|
|
//ExtendedFlycam.Inst.QuanJing();
|
|
//if (BoolMonitor.Value)
|
|
{
|
|
|
|
WebInteraction.Inst.isWorkPlay = true;
|
|
WebInteraction.Inst.OpenTicket();
|
|
}
|
|
ExtendedFlycam.Inst.QieHuan(Menu.M_全景监控_现场作业);
|
|
CabinetUIManager.ChangeMenu(Menu.M_全景监控_现场作业);
|
|
}
|
|
break;
|
|
case "Toggle_摄像头":
|
|
{
|
|
init(Menu.M_全景监控_摄像头);
|
|
//ExtendedFlycam.Inst.QuanJing();
|
|
PatternChoose.Inst.transform.Find("Panel搜索框").GetComponent<SearchName>().LoadCabinet(SearchName.SearchType.机柜);
|
|
ExtendedFlycam.Inst.QieHuan(Menu.M_全景监控_摄像头);
|
|
CabinetUIManager.ChangeMenu(Menu.M_全景监控_摄像头);
|
|
ExtendedFlycam.Inst.peiDianShi[1].GetComponent<TransparentGlow>().F1();
|
|
ExtendedFlycam.Inst.jiFang[1].GetComponent<TransparentGlow>().F1();
|
|
for (int i = 0; i < clickEventLens.Count; i++)
|
|
{
|
|
StartCoroutine(clickEventLens[i].TwinkleLens(0.5f));
|
|
}
|
|
}
|
|
break;
|
|
case "Toggle_机柜容量":
|
|
{
|
|
rongLaing.SetActive(true);
|
|
init(Menu.M_数字孪生_机柜容量);
|
|
//ExtendedFlycam.Inst.QuanJing();
|
|
PatternChoose.Inst.transform.Find("Panel搜索框").GetComponent<SearchName>().LoadCabinet(SearchName.SearchType.机柜);
|
|
GameManager.Inst.DisplayCapacity(ison);
|
|
ExtendedFlycam.Inst.QieHuan(Menu.M_数字孪生_机柜容量);
|
|
CabinetUIManager.ChangeMenu(Menu.M_数字孪生_机柜容量);
|
|
}
|
|
break;
|
|
case "Toggle_接地网":
|
|
{
|
|
FloorController.Inst.FloorTransparent();
|
|
init(Menu.M_数字孪生_接地网);
|
|
//ExtendedFlycam.Inst.QuanJing();
|
|
ExtendedFlycam.Inst.QieHuan(Menu.M_数字孪生_接地网);
|
|
CabinetUIManager.ChangeMenu(Menu.M_数字孪生_接地网);
|
|
}
|
|
break;
|
|
case "Toggle_线缆链接":
|
|
{
|
|
init(Menu.M_数字孪生_线缆连接_展示);
|
|
//ExtendedFlycam.Inst.QuanJing();
|
|
//CreateLine createLine = PatternChoose.Inst.huaXian;
|
|
createLine.OnMenuChanged(Menu.M_数字孪生_线缆连接_展示);
|
|
ExtendedFlycam.Inst.QieHuan(Menu.M_数字孪生_线缆连接_展示);
|
|
CabinetUIManager.ChangeMenu(Menu.M_数字孪生_线缆连接_展示);
|
|
}
|
|
break;
|
|
case "Toggle_场景管理":
|
|
{
|
|
init(Menu.M_数字孪生_场景管理);
|
|
//ExtendedFlycam.Inst.QuanJing();
|
|
//GameManager.Inst.power_open();
|
|
//GameManager.Inst.objectToShow_add.SetActive(true);
|
|
var SN1 = GameManager.Inst.objectToShow_add.GetComponent<SearchName1>();
|
|
SN1.hide_menu();
|
|
ExtendedFlycam.Inst.QieHuan(Menu.M_数字孪生_场景管理);
|
|
CabinetUIManager.ChangeMenu(Menu.M_数字孪生_场景管理);
|
|
}
|
|
break;
|
|
case "Toggle_智能巡检":
|
|
{
|
|
init(Menu.M_数字孪生_智能巡检);
|
|
//ExtendedFlycam.Inst.QuanJing();
|
|
WebInteraction.Inst.Patrolvideo_open();
|
|
GameManager.Inst.search_box.SetActive(false);
|
|
ExtendedFlycam.Inst.QieHuan(Menu.M_数字孪生_智能巡检);
|
|
CabinetUIManager.ChangeMenu(Menu.M_数字孪生_智能巡检);
|
|
ExtendedFlycam.Inst.room = ExtendedFlycam.Room.None;
|
|
}
|
|
break;
|
|
case "Toggle_温度":
|
|
{
|
|
StartCoroutine(Loadinfo(Menu.M_全景监控_温度, (x) =>
|
|
{
|
|
if (string.IsNullOrEmpty(x)) return;
|
|
init(Menu.M_全景监控_温度);
|
|
//ExtendedFlycam.Inst.QuanJing();
|
|
PatternChoose.Inst.transform.Find("Panel搜索框").GetComponent<SearchName>().LoadCabinet(SearchName.SearchType.机柜);
|
|
ExtendedFlycam.Inst.QieHuan(Menu.M_全景监控_温度);
|
|
CabinetUIManager.ChangeMenu(Menu.M_全景监控_温度);
|
|
}));
|
|
}
|
|
break;
|
|
case "Toggle_湿度":
|
|
{
|
|
init(Menu.M_全景监控_湿度);
|
|
//ExtendedFlycam.Inst.QuanJing();
|
|
PatternChoose.Inst.transform.Find("Panel搜索框").GetComponent<SearchName>().LoadCabinet(SearchName.SearchType.机柜);
|
|
ExtendedFlycam.Inst.QieHuan(Menu.M_全景监控_湿度);
|
|
CabinetUIManager.ChangeMenu(Menu.M_全景监控_湿度);
|
|
}
|
|
break;
|
|
case "Toggle_烟感":
|
|
{
|
|
init(Menu.M_全景监控_烟感);
|
|
//ExtendedFlycam.Inst.QuanJing();
|
|
PatternChoose.Inst.transform.Find("Panel搜索框").GetComponent<SearchName>().LoadCabinet(SearchName.SearchType.机柜);
|
|
ExtendedFlycam.Inst.QieHuan(Menu.M_全景监控_烟感);
|
|
CabinetUIManager.ChangeMenu(Menu.M_全景监控_烟感);
|
|
}
|
|
break;
|
|
case "Toggle_水浸":
|
|
{
|
|
init(Menu.M_全景监控_水浸);
|
|
//ExtendedFlycam.Inst.QuanJing();
|
|
PatternChoose.Inst.transform.Find("Panel搜索框").GetComponent<SearchName>().LoadCabinet(SearchName.SearchType.机柜);
|
|
ExtendedFlycam.Inst.QieHuan(Menu.M_全景监控_水浸);
|
|
CabinetUIManager.ChangeMenu(Menu.M_全景监控_水浸);
|
|
}
|
|
break;
|
|
case "Toggle_线缆连接展示":
|
|
{
|
|
init(Menu.M_数字孪生_线缆连接_展示);
|
|
//ExtendedFlycam.Inst.QuanJing();
|
|
|
|
//PatternChoose.Inst.transform.Find("Panel搜索框").GetComponent<SearchName>().LoadCabinet(SearchName.SearchType.线缆_展示);
|
|
createLine.OnMenuChanged(Menu.M_数字孪生_线缆连接_展示);
|
|
ExtendedFlycam.Inst.QieHuan(Menu.M_数字孪生_线缆连接_展示);
|
|
CabinetUIManager.ChangeMenu(Menu.M_数字孪生_线缆连接_展示);
|
|
}
|
|
break;
|
|
case "Toggle_线缆连接配置":
|
|
{
|
|
init(Menu.M_数字孪生_线缆连接_配置);
|
|
//ExtendedFlycam.Inst.QuanJing();
|
|
//GameManager.Inst.power_open();
|
|
ExtendedFlycam.Inst.QieHuan(Menu.M_数字孪生_线缆连接_配置);
|
|
CabinetUIManager.ChangeMenu(Menu.M_数字孪生_线缆连接_配置);
|
|
}
|
|
break;
|
|
case "Toggle_线缆组配置":
|
|
{
|
|
LineGroupManager.Instance.ShowPanel();
|
|
SecondConfirmPanel.Instance.panel_object.SetActive(false);
|
|
init(Menu.M_数字孪生_线缆组配置);
|
|
CabinetUIManager.ChangeMenu(Menu.M_数字孪生_线缆组配置);
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
createLine.deletxianLan(CabinetUIManager.Instance.current_menu);
|
|
if (toggles[index].name == "Toggle_线缆连接展示" || toggles[index].name == "Toggle_线缆连接配置" ||
|
|
toggles[index].name == "Toggle_线缆组配置" || toggles[index].name == "Toggle_线缆链接")
|
|
{
|
|
xianlanpz.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
xianlanpz.SetActive(false);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 按键切换初始化
|
|
/// </summary>
|
|
public void UI_init(string toolname = null)
|
|
{
|
|
PatternChoose.Inst.xunJianImg.gameObject.SetActive(false);
|
|
WebInteraction.Inst.CloseVideo(WebInteraction.Inst.current_videoNumber);
|
|
WebInteraction.Inst.Patrolvideo_close();
|
|
GameManager.Inst.power_close();
|
|
GameManager.Inst.CloseHighlight();
|
|
|
|
if (GameManager.Inst.objectToShow_add.activeSelf)
|
|
{
|
|
var SN1 = GameManager.Inst.objectToShow_add.GetComponent<SearchName1>();
|
|
SN1.hide_menu();
|
|
GameManager.Inst.objectToShow_add.SetActive(false);
|
|
}
|
|
GameManager.Inst.stagingPanel.SetActive(false);
|
|
GameManager.Inst.editorMenu.gameObject.SetActive(false);
|
|
|
|
rongLaing.SetActive(false);
|
|
FloorController.Inst.FloorNormal();
|
|
|
|
LineGroupManager.Instance.HidePanel();
|
|
|
|
for (int i = 0; i < GameManager.Inst.pop_ups.Count; i++)
|
|
{
|
|
GameManager.Inst.pop_ups[i].SetActive(false);
|
|
}
|
|
|
|
for (int i = 0; i < CabinetUIManager.Instance.cabinet_ui_base_list.Count; i++)
|
|
{
|
|
if (CabinetUIManager.Instance.cabinet_ui_base_list[i].gameObject.name != "智能巡检")
|
|
{
|
|
CabinetUIManager.Instance.cabinet_ui_base_list[i].gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
|
|
public IEnumerator Loadinfo(Menu menu, Action<string> callback)
|
|
{
|
|
if (menu == Menu.M_全景监控_温度)
|
|
{
|
|
yield return StartCoroutine(GameManager.Inst.init_ENV((x) =>
|
|
{
|
|
if (string.IsNullOrEmpty(x))
|
|
return;
|
|
GameManager.Inst.Load_ENV();
|
|
callback?.Invoke("1");
|
|
}));
|
|
}
|
|
else if (menu == Menu.M_全景监控_设备告警)
|
|
{
|
|
yield return StartCoroutine(GameManager.Inst.init_TmsAlarm((x) =>
|
|
{
|
|
if (string.IsNullOrEmpty(x))
|
|
return;
|
|
GameManager.Inst.Load_TmsAlarm();
|
|
callback?.Invoke("1");
|
|
}));
|
|
}
|
|
}
|
|
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
|
|
public void init(Menu menu)
|
|
{
|
|
if (WebInteraction.Inst.isWorkPlay && menu != Menu.M_全景监控_现场作业)
|
|
WebInteraction.Inst.CloseTicket();
|
|
|
|
GameObject createLine = PatternChoose.Inst.xianlan.gameObject;
|
|
if (!CheckAllChildrenActive(createLine.gameObject) && menu != Menu.M_数字孪生_线缆连接_展示)
|
|
{
|
|
for (int i = 0; i < createLine.transform.childCount; i++)
|
|
{
|
|
createLine.transform.GetChild(i).gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
if (menu == Menu.M_数字孪生_线缆连接_配置 || menu == Menu.M_数字孪生_场景管理 ||
|
|
menu == Menu.M_数字孪生_线缆组配置)
|
|
{
|
|
for (int i = 0; i < CabinetUIManager.Instance.door_list.Count; i++)
|
|
{
|
|
CabinetUIManager.Instance.door_list[i].gameObject.SetActive(false);
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
for (int i = 0; i < CabinetUIManager.Instance.door_list.Count; i++)
|
|
{
|
|
CabinetUIManager.Instance.door_list[i].gameObject.SetActive(true);
|
|
}
|
|
}
|
|
|
|
if (menu == Menu.M_数字孪生_机柜容量 || menu == Menu.M_数字孪生_场景管理)
|
|
{
|
|
if (CabinetUIManager.Instance.uPosItems[0].instruct.gameObject.activeInHierarchy)
|
|
return;
|
|
for (int i = 0; i < CabinetUIManager.Instance.uPosItems.Count; i++)
|
|
{
|
|
CabinetUIManager.Instance.uPosItems[i].instruct.gameObject.SetActive(true);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (!CabinetUIManager.Instance.uPosItems[0].instruct.gameObject.activeInHierarchy)
|
|
return;
|
|
for (int i = 0; i < CabinetUIManager.Instance.uPosItems.Count; i++)
|
|
{
|
|
CabinetUIManager.Instance.uPosItems[i].instruct.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
if (menu == Menu.M_数字孪生_智能巡检)
|
|
ExtendedFlycam.Inst.CameraRT.enabled = false;
|
|
else
|
|
ExtendedFlycam.Inst.CameraRT.enabled = true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 判断父物体下子物体是否都为隐藏
|
|
/// </summary>
|
|
/// <param name="parent"></param>
|
|
/// <returns></returns>
|
|
bool CheckAllChildrenActive(GameObject parent)
|
|
{
|
|
int childCount = parent.transform.childCount;
|
|
for (int i = 0; i < childCount; i++)
|
|
{
|
|
GameObject child = parent.transform.GetChild(i).gameObject;
|
|
if (child.activeSelf)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
}
|