using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using Blue; namespace GHZLangChao { public class BasicDeviceControl : AbstractController { [SerializeField] private Toggle Arrow_Toggle; //箭头toggle [SerializeField] private Image ArrowToggleBackground; // 箭头toggle的背景 [SerializeField] private GameObject FaultPanel; // 故障面板 [SerializeField] private Transform FaultPanelContent;// 故障面板Item父物体 [SerializeField] private Button Nav_Btn; // 导航按钮 private bool isInit=false; private void Awake() { this.RegisterEvent(SetShowDeviceTransform); Nav_Btn.onClick.AddListener(StartNav); Arrow_Toggle.onValueChanged.AddListener((e) => { if(!isInit) Init(); if(e) ArrowToggleBackground.enabled = false; else ArrowToggleBackground.enabled = true; }); UICallManager.Instance.GetDeviceTransform(); } public void ShowChoose() { ScenesManager.Instance.showWindow(ScenesManager.SceneType.ShowChoose); } /// /// 初始化数据 /// private void Init() { isInit = true; // 初始化故障面板 List ListAlarmData = UICallManager.Instance.GetAlarmData(); for (int i = 0; i < ListAlarmData.Count;i++) { GameObject go = Instantiate(InstantiateSystem.Instance.BlueObject.FaultPanel_Item,FaultPanelContent); FaultPanel_Item item = go.GetComponent(); item.Init(ListAlarmData[i]); go.name = ListAlarmData[i].title; } for (int i = 0; i < ListAlarmData.Count;i++) { GameObject go = Instantiate(InstantiateSystem.Instance.BlueObject.FaultPanel_Item,FaultPanelContent); FaultPanel_Item item = go.GetComponent(); item.Init(ListAlarmData[i]); go.name = ListAlarmData[i].title; } } #region UI监听 private static AlarmData mAlarmData; public static AlarmData AlarmData { get => mAlarmData; set => mAlarmData = value; } private void StartNav() { ScenesManager.Instance.showWindow(ScenesManager.SceneType.ShowXunJian); ShowXunJian.Instance.gotoWindow(ScenesManager.SceneType.ShowDH); BladeServerManager.Instance.isDaoHang = true; XunJianManager.Instance.FaultChange(); (SceneIOCContainer.Instance.Pull("ShowChoose") as GameObject).SetActive(false); MachineObj obj = UICallManager.Instance.QueryMachineObj(AlarmData.deviceId); if (obj != null) UICallManager.Instance.NavigatorServer(obj); else Debug.LogError(" 未查找到设备 " + AlarmData.deviceId + " " + AlarmData.deviceName); } #endregion #region 事件监听 private void SetShowDeviceTransform(ShowDeviceEvent e) { transform.position = e.ShowDeviceTransform.position; transform.rotation = e.ShowDeviceTransform.rotation; this.UnRegisterEvent(SetShowDeviceTransform); } #endregion } }