DCS/ruiyiweiUX/Assets/GeneralTools/Scripts/Always/MessageBox/SetMessageShow.cs

41 lines
1.2 KiB
C#
Raw Permalink Normal View History

2026-06-09 13:59:11 +08:00
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace GeneralTools
{
public class SetMessageShow : MonoBehaviour
{
public Button closeBtn;
public Button confirmBtn;
public Text buttonText;
public Text tittleText;
public Text showText;
public void Show(string tittleStr, string messageStr, string buttonStr, Action action, Action closeAction)
{
closeBtn.gameObject.SetActive(false);
closeBtn.onClick.RemoveAllListeners();
confirmBtn.onClick.RemoveAllListeners();
closeBtn.onClick.AddListener(() => { closeAction(); });
confirmBtn.onClick.AddListener(() => { action(); });
buttonText.text = buttonStr;
tittleText.text = tittleStr;
showText.text = messageStr;
gameObject.SetActive(true);
}
public void Show(MessageShowClass message, Action closeAction)
{
Show(message.tittleStr, message.messageStr, message.buttonStr, message.action, closeAction);
}
public void Hide()
{
gameObject.SetActive(false);
}
}
}