Ejemplo n.º 1
0
        public static void Show(string text, string caption, MessageBoxButton[] btns)
        {
#if MESSAGEBOX_DEBUG
            Debug.LogFormat("MessageBox.Show {0} frame={1}", text, Time.frameCount);
#endif
            if (m_messageBox != null)
            {
                m_messageBox.gameObject.SetActive(true);
                m_messageBox.ShowContent(text, caption, btns);
#if MESSAGEBOX_DEBUG
                Debug.LogFormat("m_messageBox.ShowContent {0} frame={1} ", text, Time.frameCount);
#endif
            }
            else if (!m_isloading)
            {
#if MESSAGEBOX_DEBUG
                Debug.LogFormat("Show {0} load asset frame={1}", text, Time.frameCount);
#endif
                m_isloading = true;
                var m_messageBoxInfo = new MessageBoxInfo();
                m_messageBoxInfo.text    = text;
                m_messageBoxInfo.caption = caption;
                m_messageBoxInfo.btns    = btns;
                // ResourcesLoader.StartCoroutine1 (LoadMessageBox (m_messageBoxInfo));
            }
        }
Ejemplo n.º 2
0
        private static void SetContent(MessageBox messageBox, MessageBoxInfo messageBoxInfo)
        {
            messageBox.text.text    = messageBoxInfo.text;
            messageBox.caption.text = messageBoxInfo.caption;

            var    btns        = messageBox.buttons;
            var    btnContents = messageBoxInfo.btns;
            Button btn;

            if (btnContents != null)
            {
                for (int i = 0; i < btns.Length; i++)
                {
                    btn = btns[i];
                    if (i < btnContents.Length)
                    {
                        btn.gameObject.SetActive(true);
                        btn.onClick.RemoveAllListeners();
                        if (btnContents[i].onClick != null)
                        {
                            btn.onClick.AddListener(btnContents[i].onClick);
                        }
                    }
                    else
                    {
                        btn.gameObject.SetActive(false);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private static IEnumerator LoadMessageBox(MessageBoxInfo m_messageBoxInfo)
        {
// #if MESSAGEBOX_DEBUG
//             Debug.LogFormat ("LoadMessageBox .LoadAssetCoroutine {0} ,frame={1}  ", m_messageBoxInfo,Time.frameCount);
// #endif
//             var req = ResourcesLoader.LoadAssetCoroutine (CUtils.GetRightFileName (MESSAGEBOX_ABNAME), CUtils.GetAssetName (MESSAGEBOX_ABNAME), typeof (GameObject));
//             yield return req;
// #if MESSAGEBOX_DEBUG
//             Debug.LogFormat ("LoadMessageBox LoadAssetCoroutine is done {0},frame={1}  ", req,Time.frameCount);
// #endif
//             var obj = (GameObject)req.data;
// #if MESSAGEBOX_DEBUG
//             Debug.LogFormat ("LoadMessageBox obj req.GetAsset<GameObject> {0} ,frame={1}  ", obj,Time.frameCount);
// #endif
//             var ins = GameObject.Instantiate (obj);
//             m_messageBox = ins.GetComponent<MessageBox> ();
//             m_isloading = false;
//             DontDestroyOnLoad (ins);
//             m_messageBox.ShowContent (m_messageBoxInfo.text, m_messageBoxInfo.caption, m_messageBoxInfo.btns);
            yield return(null);
        }