using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class SelectMessageBox : PrefabInstance<SelectMessageBox>
{
public static SelectMessageBox Instance;
public Text hintIfoTxt;
public Button acceptBtn;
public Button refuseBtn;
public Button closeBtn;
public Text acceptTxt;
public Text refuseTxt;
static Action accept;
static Action refuse;
private void Awake()
{
Instance = this;
}
// Start is called before the first frame update
void Start()
{
acceptBtn.onClick.AddListener(OnClickAcceptBtn);
refuseBtn.onClick.AddListener(OnClickRefuseBtn);
closeBtn.onClick.AddListener(() => { Destroy(gameObject); });
}
public static void OpenSelectMessageBox(string info, string _acceptTxt, string _refuseTxt, Action _accept, Action _refuse)
{
SelectMessageBox.Get(GameStart.UIHierarchys[5]);
Instance.acceptTxt.text = _acceptTxt;
Instance.refuseTxt.text = _refuseTxt;
if (Instance)
{
Instance.hintIfoTxt.text = info;
accept = _accept;
refuse = _refuse;
}
}
private void OnClickAcceptBtn()
{
if (accept != null)
accept.Invoke();
Destroy(gameObject);
}
private void OnClickRefuseBtn()
{
if (refuse != null)
refuse.Invoke();
Destroy(gameObject);
}
}
跟发布的消息框(一)一样,用了个UI小框架。