HAARFTE/Assets/DemoGame/GameScript/Hotfix/UI/Logic/DialogueUI.cs

39 lines
991 B
C#

using System;
using TMPro;
using UnityEngine.UI;
namespace ZC
{
[UIType(UIType.DialogueUI)]
public class DialogueUI : UIBase
{
private TMP_Text txt_Title;
private TMP_Text txt_Content;
private Button btn_Close;
private Action callback;
public override void Init()
{
base.Init();
txt_Title = GetValue<TMP_Text>("txt_Title");
txt_Content = GetValue<TMP_Text>("txt_Content");
btn_Close = GetValue<Button>("btn_Close");
btn_Close.onClick.AddListener(ClickClose);
}
public void SetData(string title, string content, Action callback = null)
{
txt_Title.text = title;
txt_Content.text = content;
this.callback = callback;
}
private void ClickClose()
{
ZCGame.UIManager.HideUI(UIType.DialogueUI);
callback?.Invoke();
callback = null;
}
}
}