using UnityEngine; using UnityEngine.UI; using QFramework; using System; using System.Collections.Generic; using TMPro; using static OperationController; namespace QFramework.Example { public class UITipWindowData : UIPanelData { public class ItemData { public string txt; public Action OnClick; } public string txt; public string audio; public List btns = new List(); } public partial class UITipWindow : UIPanel { ResLoader loader; protected override void OnInit(IUIData uiData = null) { mData = uiData as UITipWindowData ?? new UITipWindowData(); // please add init code here TypeEventSystem.Global.Register((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject); } private void OnStepChanged(StepStatusOnChange change) { Hide(); } protected override void OnOpen(IUIData uiData = null) { mData = uiData as UITipWindowData ?? new UITipWindowData(); TypeEventSystem.Global.Register(OnStepChanged).UnRegisterWhenDisabled(gameObject); if (mData.txt.Contains("{Score}")) { mData.txt = mData.txt.Replace("{Score}", ScoreController.Instance.GetCurScore().ToString()); } Label.text = mData.txt; BtnContent.RemoveAllChildren(); if (mData != null) { foreach (var item in mData.btns) { GameObject obj = GameObject.Instantiate(BtnPrefab.gameObject, BtnContent); obj.transform.Find("Label").GetComponent().text = item.txt; obj.name = item.txt; obj.GetComponent