using UnityEngine; using UnityEngine.UI; using QFramework; using System.Collections.Generic; using TMPro; using static OperationController; namespace QFramework.Example { public class UIBackPackData : UIPanelData { public List devices; public bool random = false; public float scrollSpeed = 25; public string position; } public partial class UIBackPack : UIPanel { ResLoader mResLoader; protected override void OnInit(IUIData uiData = null) { mData = uiData as UIBackPackData ?? new UIBackPackData(); mResLoader = ResLoader.Allocate(); TypeEventSystem.Global.Register(OnModuleQuit).UnRegisterWhenGameObjectDestroyed(gameObject); // please add init code here } protected override void OnOpen(IUIData uiData = null) { Content.RemoveAllChildren(); foreach (var device in mData.devices) { var item = DeviceController.Instance.GetDevice(device); if (item == null) { Debug.LogError(device + ":没有找到对应的Device配置"); return; } GameObject obj = GameObject.Instantiate(ItemPrefab.gameObject, Content); obj.name = item.Name; obj.transform.Find("Name").GetComponent().text = item.Name; Image icon = obj.transform.Find("IconBg/Icon").GetComponent(); var localImageUrl = Global.deviceIconsPath + item.Icon; GameObject right = icon.transform.Find("Right").gameObject; GameObject wrong = icon.transform.Find("Wrong").gameObject; GameObject Selected = icon.transform.Find("Selected").gameObject; mResLoader.Add2Load(localImageUrl.ToNetImageResName(), (bool success, IRes res) => { if (success) { icon.sprite = Utility.GetSprite(res.Asset as Texture2D); } }); Button btn = obj.GetComponent