using UnityEngine; using UnityEngine.UI; using System.Collections.Generic; using TMPro; using XMLTool; using UnityEngine.EventSystems; using System; 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; Dictionary dict = new Dictionary(); 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 } private void OnPickDeviceHandler(OnPickDevice device) { ItemFactory(device.device); mResLoader.LoadAsync(); } public void ItemFactory(Device item) { if (dict.ContainsKey(item) == false) { 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