using UnityEngine; using UnityEngine.UI; using QFramework; using System.Collections.Generic; using TMPro; namespace QFramework.Example { public class UITextQuestionData : UIPanelData { public string title; public List options = new List(); public List answers = new List(); public List btns = new List(); public float waitCloseTime = -1; public bool showAnswer = false; } public partial class UITextQuestion : UIPanel { protected override void OnInit(IUIData uiData = null) { mData = uiData as UITextQuestionData ?? new UITextQuestionData(); // please add init code here } protected override void OnOpen(IUIData uiData = null) { mData = uiData as UITextQuestionData ?? new UITextQuestionData(); Title.text = mData.title; OptionContent.transform.RemoveAllChildren(); for (int i = 0; i < mData.options.Count; i++) { var item = mData.options[i]; GameObject obj = GameObject.Instantiate(OptionPrefab.gameObject, OptionContent.transform); obj.transform.Find("Label").GetComponent().text = item; obj.name = (i + 1).ToString(); } BtnContent.RemoveAllChildren(); foreach (var item in mData.btns) { GameObject obj = GameObject.Instantiate(BtnPrefab.gameObject, BtnContent); obj.name = item; var label = obj.transform.Find("Label").GetComponent(); label.text = item; obj.GetComponent