2024-12-14 18:27:59 +08:00
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
using QFramework;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using TMPro;
|
2024-12-30 19:15:34 +08:00
|
|
|
using static OperationController;
|
2024-12-14 18:27:59 +08:00
|
|
|
|
|
|
|
|
namespace QFramework.Example
|
|
|
|
|
{
|
|
|
|
|
public class UITipWindowData : UIPanelData
|
|
|
|
|
{
|
|
|
|
|
public class ItemData
|
|
|
|
|
{
|
|
|
|
|
public string txt;
|
|
|
|
|
public Action OnClick;
|
|
|
|
|
}
|
|
|
|
|
public string txt;
|
|
|
|
|
public List<ItemData> btns = new List<ItemData>();
|
|
|
|
|
}
|
|
|
|
|
public partial class UITipWindow : UIPanel
|
|
|
|
|
{
|
|
|
|
|
protected override void OnInit(IUIData uiData = null)
|
|
|
|
|
{
|
|
|
|
|
mData = uiData as UITipWindowData ?? new UITipWindowData();
|
|
|
|
|
// please add init code here
|
|
|
|
|
|
2024-12-30 19:15:34 +08:00
|
|
|
TypeEventSystem.Global.Register<StepStatusOnChange>(OnStepChanged);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnStepChanged(StepStatusOnChange change)
|
|
|
|
|
{
|
|
|
|
|
Hide();
|
2024-12-14 18:27:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnOpen(IUIData uiData = null)
|
|
|
|
|
{
|
|
|
|
|
mData = uiData as UITipWindowData ?? new UITipWindowData();
|
|
|
|
|
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<TextMeshProUGUI>().text = item.txt;
|
|
|
|
|
obj.GetComponent<Button>().onClick.AddListener(() =>
|
|
|
|
|
{
|
|
|
|
|
item.OnClick?.Invoke();
|
|
|
|
|
Hide();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnShow()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnHide()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnClose()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|