using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
namespace GameLogic {
///
/// 更新提示框
///
public class UpdateMsgBox : MonoBehaviour
{
///
/// 左边的按钮
///
[SerializeField]
Button buttonL;
///
/// 左边按钮文字
///
[SerializeField]
Text buttonLText;
///
/// 右边按钮
///
[SerializeField]
Button buttonR;
///
/// 右边按钮文字
///
[SerializeField]
Text buttonRText;
///
/// 右边按钮
///
[SerializeField]
Button buttonC;
///
/// 右边按钮文字
///
[SerializeField]
Text buttonCText;
///
/// 消息
///
[SerializeField]
Text msg;
///
/// title
///
[SerializeField]
Text title;
///
/// 点击回调
///
UnityAction action;
protected void Awake()
{
buttonL.onClick.AddListener(LClickHandler);
buttonR.onClick.AddListener(RClickHandler);
buttonC.onClick.AddListener(CClickHandler);
title.text = SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.TIPS);
}
private void ClosePanel()
{
CallBack(-1);
}
///
/// 左边按钮点击
///
private void LClickHandler()
{
CallBack(0);
}
///
/// 右边按钮点击
///
private void RClickHandler()
{
CallBack(1);
}
///
/// 右边按钮点击
///
private void CClickHandler()
{
CallBack(2);
}
///
/// 回调
///
///
private void CallBack(int i)
{
this.gameObject.SetActive(false);
if (action != null)
{
action(i);
}
}
///
/// 显示提示框,有两个按钮
///
///
///
///
public void Show(string strL, string strR, string msg, UnityAction action)
{
this.gameObject.SetActive(true);
this.buttonL.gameObject.SetActive(true);
this.buttonR.gameObject.SetActive(true);
this.buttonC.gameObject.SetActive(false);
this.buttonLText.text = strL;
this.buttonRText.text = strR;
this.msg.text = msg;
this.action = action;
}
///
/// 显示对话框,只有一个按钮
///
///
///
///
public void Show(string strc, string msg, UnityAction action)
{
this.gameObject.SetActive(true);
this.buttonL.gameObject.SetActive(false);
this.buttonR.gameObject.SetActive(false);
this.buttonC.gameObject.SetActive(true);
this.buttonCText.text = strc;
this.msg.text = msg;
this.action = action;
}
///
/// 显示对话框,没有按钮
///
///
///
///
public void Show(string msg)
{
this.gameObject.SetActive(true);
this.buttonL.gameObject.SetActive(false);
this.buttonR.gameObject.SetActive(false);
this.buttonC.gameObject.SetActive(false);
this.msg.text = msg;
}
}
}