using System.Collections; using System.Collections.Generic; using DG.Tweening; using Sirenix.OdinInspector; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; public class UI_SelectDevicePanel : BasePanel { private List allSchemeName; private Dictionary allDeviceTypes; public void Init() { allSchemeName = GameManager.DataMgr.GetAllSchemeName(); allDeviceTypes = GameManager.DataMgr.GetAllDeviceTypes(); CreatTitleAndBtnItem(); } void CreatTitleAndBtnItem() { var onlyDeviceHashSet = new HashSet(); foreach (var scheme in allSchemeName) { if (!onlyDeviceHashSet.Contains(scheme.deviceTypeId)) //没有这个设备类型ID就添加唯一标识 { onlyDeviceHashSet.Add(scheme.deviceTypeId); var titleItem = GameManager.ResourcesMgr.Load(Const.UI_Item + "UI_SelectDevicePanel/titleItem"); titleItem.transform.parent = GetControl("DeviceScrollView").content; if (allDeviceTypes.TryGetValue(scheme.deviceTypeId, out TB_DeviceType deviceNameItem)) { titleItem.GetComponentInChildren().text = deviceNameItem.deviceTypeName; var currentIdList = allSchemeName.FindAll(s => s.deviceTypeId == scheme.deviceTypeId); //遍历每个当前设备类型,并生成按钮 currentIdList.ForEach(x => { var deviceItemBtn = GameManager.ResourcesMgr.Load(Const.UI_Item + "UI_SelectDevicePanel/deviceItemBtn"); //按钮的父节点是标题的父节点content deviceItemBtn.transform.parent = titleItem.transform.parent; deviceItemBtn.GetComponentInChildren().text = x.schemeName; var deviceBtnAComponent = deviceItemBtn.GetComponent