59 lines
1.5 KiB
C#
59 lines
1.5 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using QFramework;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using static OperationController;
|
|
using System;
|
|
|
|
namespace QFramework.Example
|
|
{
|
|
public class UIBtnsData : UIPanelData
|
|
{
|
|
public List<string> btns = new List<string>();
|
|
}
|
|
public partial class UIBtns : UIPanel
|
|
{
|
|
protected override void OnInit(IUIData uiData = null)
|
|
{
|
|
mData = uiData as UIBtnsData ?? new UIBtnsData();
|
|
// please add init code here
|
|
TypeEventSystem.Global.Register<StepStatusOnChange>(OnStepChanged);
|
|
}
|
|
|
|
private void OnStepChanged(StepStatusOnChange change)
|
|
{
|
|
Hide();
|
|
}
|
|
|
|
protected override void OnOpen(IUIData uiData = null)
|
|
{
|
|
mData = uiData as UIBtnsData ?? new UIBtnsData();
|
|
BtnContent.RemoveAllChildren();
|
|
foreach (var item in mData.btns)
|
|
{
|
|
GameObject obj = GameObject.Instantiate(BtnPrefab.gameObject, BtnContent);
|
|
obj.name = item;
|
|
obj.transform.Find("Label").GetComponent<TextMeshProUGUI>().text = item;
|
|
obj.GetComponent<Button>().onClick.AddListener(() =>
|
|
{
|
|
Hide();
|
|
});
|
|
}
|
|
|
|
}
|
|
|
|
protected override void OnShow()
|
|
{
|
|
}
|
|
|
|
protected override void OnHide()
|
|
{
|
|
}
|
|
|
|
protected override void OnClose()
|
|
{
|
|
}
|
|
}
|
|
}
|