using DG.Tweening; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using ZXK.Framework; /******************************************************************************* *Create By CG *Function 设备认知数据处理 *******************************************************************************/ namespace ZXK.BYSS { public class CognizePanel : UIBase { protected override void Awake() { base.Awake(); } private void Start() { Transform nameItemParent = GetWedage("Content_N").transform; GameObject nameItemPrefab = nameItemParent.Find("EquipmentNameItemPrefab").gameObject; //初始化数据 List equipArray = AppManagement.Instance._CognizeData._EquipmentData[ UTility.EnumCtrl.GetEnumDescription(AppManagement.Instance._CurType)]; for (int i = 0; i < equipArray.Count; i++) { GameObject modelItem = Instantiate(nameItemPrefab, nameItemParent); modelItem.transform.name = equipArray[i]._ModelID; modelItem.GetComponentInChildren().text = equipArray[i]._ModelName; modelItem.SetActive(true); Toggle modelTog = modelItem.transform.GetComponent(); modelTog.onValueChanged.AddListener((isOn) => { if (isOn) { EquipmentInfo temp = EquipmentInfo.Default; List tempArray = AppManagement.Instance._CognizeData._EquipmentData[ UTility.EnumCtrl.GetEnumDescription(AppManagement.Instance._CurType)]; for (int a = 0; a < tempArray.Count; a++) { if (equipArray[a]._ModelID.Equals(modelTog.transform.name)) { temp = equipArray[a]; } } ClickEquipmentArgs args = new() { info =temp, }; EventCenterManager.Instance.Dispatch(EventEnum.ClickEquipment, this, args); Toggle[] togChildrens = nameItemParent.GetComponentsInChildren(); for (int i = 0; i < togChildrens.Length; i++) { //添加toggleGroup togChildrens[i].group = GetWedage("Content_N").transform.GetComponent(); if (!togChildrens[i].name.Equals(modelTog.name)) { // Debug.Log(togChildrens[i].name+"名字是???"); togChildrens[i].isOn = false; } } } }); } GetWedage("Content_N").transform.GetComponentInChildren().isOn = true; //目录伸缩控制 AddEventListener("CatalogStretchTog_N", UIEventType.OnToggleValueChanged, (isOn) => { if (isOn) { GetWedage("CatalogScrollView_N").GetComponent().DOAnchorPosX(10.0f, 0.5f); } else { GetWedage("CatalogScrollView_N").GetComponent().DOAnchorPosX(-200.0f, 0.5f); } }); //说明伸缩控制 AddEventListener("ExplainStretchTog_N", UIEventType.OnToggleValueChanged, (isOn) => { if (isOn) { GetWedage("ExplainView_N").GetComponent().DOAnchorPosX(-10.0f, 0.5f); } else { GetWedage("ExplainView_N").GetComponent().DOAnchorPosX(300.0f, 0.5f); } }); //一键拆卸 AddEventListener("SplitBtn_N", UIEventType.OnButtonClick, () => { EventCenterManager.Instance.Dispatch(EventEnum.SplitEquipment, this, null); }); //一键合成 AddEventListener("CombineBtn_N", UIEventType.OnButtonClick, () => { EventCenterManager.Instance.Dispatch(EventEnum.CombineEquipment, this, null); }); } /// /// 显示选中物体信息 /// /// public void ShowEquipment(string equipmentExplain,string equipmentName) { SetText("ExplainContent_N", equipmentExplain); SetText("ModelNameTxt_N", equipmentName); } protected override void OnDestroy() { base.OnDestroy(); } } }