123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- 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<ShowDeviceEvent>(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);
- }
- /// <summary>
- /// 初始化数据
- /// </summary>
- private void Init()
- {
- isInit = true;
- // 初始化故障面板
- List<AlarmData> 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<FaultPanel_Item>();
- 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<FaultPanel_Item>();
- 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<ShowDeviceEvent>(SetShowDeviceTransform);
- }
- #endregion
- }
- }
|