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

45 lines
1.2 KiB
C#
Raw Normal View History

2024-11-07 23:17:41 +08:00
using System;
using TMPro;
using UnityEngine.UI;
namespace ZC
{
[UIType(UIType.DialogueUI)]
public class DialogueUI : UIBase
{
// private TMP_Text txt_Title;
2024-11-07 23:17:41 +08:00
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");
2024-11-07 23:17:41 +08:00
txt_Content = GetValue<TMP_Text>("txt_Content");
btn_Close = GetValue<Button>("btn_Close");
btn_Close.onClick.AddListener(ClickClose);
}
public void SetData(string content, Action callback = null)
{
// txt_Title.text = title;
txt_Content.text = content;
this.callback = callback;
}
2024-11-07 23:17:41 +08:00
public void SetData(string title, string content, Action callback = null)
{
// txt_Title.text = title;
2024-11-07 23:17:41 +08:00
txt_Content.text = content;
this.callback = callback;
}
private void ClickClose()
{
EventManager.Instance.FireNow(this, new UIHideOrShowEventArgs(UIType.DialogueUI));
2024-11-07 23:17:41 +08:00
callback?.Invoke();
}
}
}