using System; using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.UI; public class MessageBoxController : MonoBehaviour { // Start is called before the first frame update //void Start() //{ //} // Update is called once per frame //void Update() //{ //} /*功能:跳出提示框。点击OK后消失 msg: 提示内容 callbackAction 绑定OK按键对应的函数*/ public static void ShowMessage(string msg, Action callbackAction = null) { GameObject messageBox = Resources.Load("MessageBox/MessageBox"); // 检测是否存在MessageBox(Clone) gameobject 是否已经存在了 GameObject existingMessageBox = GameObject.Find("MessageBox(Clone)"); if (existingMessageBox == null) { Instantiate(messageBox); } else { //Debug.Log("MessageBox already exists, destroying the old one."); Debug.Log("MessageBox already exists, destroying the old one."); } if (messageBox != null) { GameObject msgBodyObject = GameObject.Find("msgBody"); GameObject btnOkObject = GameObject.Find("btn_OK"); msgBodyObject.GetComponent().text = msg; Button btnOk = btnOkObject.GetComponent