XunJianManager.cs 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. using System.Collections.Generic;
  2. using TMPro;
  3. using UnityEngine;
  4. using UnityEngine.Events;
  5. using UnityEngine.UI;
  6. using Blue;
  7. namespace GHZLangChao
  8. {
  9. public class XunJianManager : SingletonMonobehaviour<XunJianManager>, IController
  10. {
  11. public bool Test = false;
  12. [SerializeField] private GameObject SearchPanel; // 搜索面板
  13. [SerializeField] private Transform SearchPanelContent; // 搜索面板Item父物体
  14. [SerializeField] private GameObject FaultPanel; // 故障面板
  15. [SerializeField] private Transform FaultPanelContent;// 故障面板Item父物体
  16. [SerializeField] private Button Serach_Btn;
  17. public Button Fault_Btn;
  18. private FontStyle FontStyleB = FontStyle.Bold;
  19. private FontStyle FontStyleN = FontStyle.Normal;
  20. [SerializeField] private TextMeshProUGUI Serach_Text;
  21. [SerializeField] private TextMeshProUGUI Fault_Text;
  22. [SerializeField] private Button Titile_Btn;
  23. [SerializeField] private Button Nav_Btn; // 导航按钮
  24. [SerializeField] private GameObject Retract_go; // 收起
  25. [SerializeField] private GameObject Expand_go; // 展开
  26. public GameObject UI_go;
  27. public UnityEvent OnReset = new UnityEvent();
  28. public UnityEvent OnRetract = new UnityEvent();
  29. public UnityEvent OnExpand = new UnityEvent();
  30. void Start()
  31. {
  32. #if UNITY_EDITOR
  33. Test = true;
  34. #endif
  35. Serach_Btn.onClick.AddListener(SerachChange);
  36. Fault_Btn.onClick.AddListener(FaultChange);
  37. Nav_Btn.onClick.AddListener(StartNav);
  38. Titile_Btn.onClick.AddListener(ClickTitle);
  39. //UICallManager.Instance.MachineRoomInit();
  40. XRRGBCamera.Instance.stopCamera();
  41. Init();
  42. }
  43. public void StartXunJain()
  44. {
  45. UI_go.SetActive(false);
  46. }
  47. public void Next()
  48. {
  49. ShowXunJian.Instance.gotoWindow(ScenesManager.SceneType.ShowDH);
  50. }
  51. public void back()
  52. {
  53. ScenesManager.Instance.showWindow(ScenesManager.SceneType.ShowChoose);
  54. // BladeServerManager.Instance.isDaoHang = false;
  55. }
  56. public void Navigationing()
  57. {
  58. // ScenesManager.Instance.showWindow(ScenesManager.SceneType.Navigationing);
  59. }
  60. /// <summary>
  61. /// 初始化数据
  62. /// </summary>
  63. private void Init()
  64. {
  65. // 初始化搜索面板
  66. List<MachineParameters> listEquipmentData = UICallManager.Instance.GetMachineRoomData("").listEquipmentData;
  67. for (int i = 0; i < listEquipmentData.Count;i++)
  68. {
  69. GameObject go = Instantiate(InstantiateSystem.Instance.BlueObject.SearchPanel_Item,SearchPanelContent);
  70. SearchPanel_Item item = go.GetComponent<SearchPanel_Item>();
  71. item.Init(listEquipmentData[i]);
  72. go.name = listEquipmentData[i].deviceName;
  73. if(string.IsNullOrEmpty(listEquipmentData[i].deviceName)) Destroy(go);
  74. }
  75. // 初始化故障面板
  76. List<AlarmData> ListAlarmData = UICallManager.Instance.GetAlarmData();
  77. for (int i = 0; i < ListAlarmData.Count;i++)
  78. {
  79. GameObject go = Instantiate(InstantiateSystem.Instance.BlueObject.FaultPanel_Item,FaultPanelContent);
  80. FaultPanel_Item item = go.GetComponent<FaultPanel_Item>();
  81. item.Init(ListAlarmData[i]);
  82. go.name = ListAlarmData[i].title;
  83. }
  84. }
  85. #region UI监听
  86. private Color colorBlue = new Color32(25,107,255,255);
  87. private Color colorWhite = new Color32(255,255,255,255);
  88. public void SerachChange()
  89. {
  90. Serach_Text.fontStyle = (FontStyles)FontStyleB;
  91. Fault_Text.fontStyle = (FontStyles)FontStyleN;
  92. Serach_Text.color = colorBlue;
  93. Fault_Text.color = Color.white;
  94. IsSerach = true;
  95. }
  96. public void FaultChange()
  97. {
  98. Serach_Text.fontStyle = (FontStyles)FontStyleN;
  99. Fault_Text.fontStyle = (FontStyles)FontStyleB;
  100. Serach_Text.color = Color.white;
  101. Fault_Text.color = colorBlue;
  102. IsSerach = false;
  103. }
  104. private static MachineParameters mMachineParameter;
  105. public static MachineParameters MachineParameters
  106. {
  107. get => mMachineParameter;
  108. set => mMachineParameter = value;
  109. }
  110. private static AlarmData mAlarmData;
  111. public static AlarmData AlarmData
  112. {
  113. get => mAlarmData;
  114. set => mAlarmData = value;
  115. }
  116. private bool IsSerach = true; // 在Search面板下点击导航
  117. private void StartNav()
  118. {
  119. if(IsSerach)
  120. {
  121. MachineObj obj = UICallManager.Instance.QueryMachineObj(MachineParameters.deviceId);
  122. if (obj != null)
  123. {
  124. UICallManager.Instance.NavigatorServer(obj);
  125. UI_go.SetActive(false);
  126. Retract_go.SetActive(false);
  127. Expand_go.SetActive(true);
  128. }
  129. else
  130. Debug.LogError(" 未查找到设备 " + MachineParameters.deviceId + " " + MachineParameters.deviceName);
  131. }
  132. else
  133. {
  134. MachineObj obj = UICallManager.Instance.QueryMachineObj(AlarmData.deviceId);
  135. if (obj != null)
  136. {
  137. UICallManager.Instance.NavigatorServer(obj);
  138. UI_go.SetActive(false);
  139. Retract_go.SetActive(false);
  140. Expand_go.SetActive(true);
  141. }
  142. else
  143. Debug.LogError(" 未查找到设备 " + AlarmData.deviceId + " " + AlarmData.deviceName);
  144. }
  145. }
  146. public void showRTC()
  147. {
  148. LangChaoRTC.Instance.showRTC(0);
  149. ScenesManager.Instance.showWindow(ScenesManager.SceneType.RoomMain);
  150. }
  151. private bool isRetract = false;
  152. private void ClickTitle()
  153. {
  154. isRetract = !isRetract;
  155. if(isRetract)
  156. OnRetract?.Invoke();
  157. else
  158. OnExpand?.Invoke();
  159. }
  160. #endregion
  161. public void OpenEidotrCanvas()
  162. {
  163. SettingMachineRoomData.Instance.EditorOpen();
  164. }
  165. private void Update()
  166. {
  167. if (Test) return;
  168. #if UNITY_EDITOR
  169. return;
  170. #endif
  171. OnReset?.Invoke();
  172. }
  173. }
  174. }