LaboratoryProtection/Assets/UnityTest/ZXL/Scripts/UI/StrongTipsUI.cs

61 lines
1.5 KiB
C#
Raw Normal View History

2023-09-14 15:36:17 +08:00
using System;
using TMPro;
2023-09-13 15:04:19 +08:00
using UnityEngine;
using UnityEngine.UI;
namespace UnityTest.ZXL
{
//强提示
2023-09-13 15:31:44 +08:00
public class StrongTipsUI : UI
2023-09-13 15:04:19 +08:00
{
public TextMeshProUGUI titleText;
public TextMeshProUGUI contentText;
public Button btnLeft;
public Button btnRight;
2023-09-14 15:36:17 +08:00
private Action _action;
public override void OnInit()
{
base.OnInit();
btnLeft.onClick.AddListener(ClickSure);
btnRight.onClick.AddListener(ClickCancel);
}
private void ClickSure()
{
UIManager.Instance().HideUI(uiType);
_action?.Invoke();
}
private void ClickCancel()
{
UIManager.Instance().HideUI(uiType);
}
2023-09-13 15:04:19 +08:00
public void SetContent(string title, string content)
{
titleText.text = title;
contentText.text = content;
}
2023-09-14 15:36:17 +08:00
public void SetContent(string title, string content, Action callback, int btnCount)
2023-09-13 15:04:19 +08:00
{
titleText.text = title;
contentText.text = content;
2023-09-14 15:36:17 +08:00
_action = callback;
2023-09-13 15:04:19 +08:00
btnLeft.gameObject.SetActive(true);
btnRight.gameObject.SetActive(true);
if (btnCount == 0)
{
btnLeft.gameObject.SetActive(false);
btnRight.gameObject.SetActive(false);
}
else if (btnCount == 1)
{
btnRight.gameObject.SetActive(false);
}
}
}
}