Example #1
0
        public static void ShowPopup(
            string messageText,
            bool enableButton = false,
            string buttonText = "OK",
            Sprite popupImage = null,
            Action onClose    = null)
        {
            if (_popupWindow == null)
            {
                GameObject popupObject = Object.Instantiate(Resources.Load("PopupWindow") as GameObject);
                _popupWindow = popupObject.GetComponent <PopupWindow>();
            }

            if (_popupQueue == null)
            {
                _popupQueue = new List <PopupParameters>();
            }

            Action onCloseOverride = onClose;

            onCloseOverride += UpdatePopupQueue;

            PopupParameters popupPars = new PopupParameters(messageText,
                                                            enableButton,
                                                            buttonText,
                                                            popupImage,
                                                            onCloseOverride);

            _popupQueue.Add(popupPars);

            if (_popupQueue.Count == 1)
            {
                _popupWindow.Show(popupPars.MessageText,
                                  popupPars.EnableButton,
                                  popupPars.ButtonText,
                                  popupPars.PopupImage,
                                  popupPars.OnClose);
            }
        }
Example #2
0
        private static void UpdatePopupQueue()
        {
            if (_popupQueue.Count == 0)
            {
                return;
            }

            _popupQueue.Remove(_popupQueue.First());

            if (_popupQueue.Count == 0)
            {
                return;
            }

            PopupParameters popupPars = _popupQueue.First();

            _popupWindow.Show(popupPars.MessageText,
                              popupPars.EnableButton,
                              popupPars.ButtonText,
                              popupPars.PopupImage,
                              popupPars.OnClose);
        }