using UnityEngine; using UnityEngine.UI; using QFramework; using System.Collections.Generic; using TMPro; using System.Linq; using DG.Tweening; namespace QFramework.Example { public class UIToolsData : UIPanelData { public List devices; public string answer; public bool SetActive = true; public string rightLable; public string wrongLabel; public string rightEvent; public string wrongEvent; public float rightScore; public float wrongScore; public string scoreStepName; } public partial class UITools : UIPanel { ResLoader mResLoader; public List answers; protected override void OnInit(IUIData uiData = null) { mData = uiData as UIToolsData ?? new UIToolsData(); // please add init code here } protected override void OnOpen(IUIData uiData = null) { TypeEventSystem.Global.Register(OnModuleQuit).UnRegisterWhenDisabled(gameObject); mResLoader = ResLoader.Allocate(); mData = uiData as UIToolsData ?? new UIToolsData(); if (string.IsNullOrEmpty(mData.answer) == false) { answers = mData.answer.Split(',')?.ToList(); } Content.RemoveAllChildren(); foreach (var device in mData.devices) { var item = DeviceController.Instance.GetDevice(device); GameObject obj = GameObject.Instantiate(ItemPrefab.gameObject, Content); obj.name = item.Name; obj.transform.Find("Name").GetComponent().text = item.Name; Image icon = obj.transform.Find("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; GameObject CurSelect = obj.transform.Find("CurSelect").gameObject; mResLoader.Add2Load(localImageUrl.ToNetImageResName(), (bool succes, IRes res) => { if (succes) { var texture2D = res.Asset as Texture2D; icon.sprite = Sprite.Create(texture2D, new Rect(0, 0, texture2D.width, texture2D.height), Vector2.one * 0.5f); } }); Button btn = obj.GetComponent