Esempio n. 1
0
        private void ShowDialogFromQueue()
        {
            SimpleUIDialogContent targetUIDContent = uiDialogContentQueue.Dequeue();

            activeDialog = true;
            dialogPanelBG.SetActive(true);
            dialogPanelAnimator.Animate_Scale(UIAnimator.Location.END);
            dialogTitle.text   = targetUIDContent.dialogTitleString;
            dialogContent.text = targetUIDContent.dialogContentString;


            foreach (Transform obj in actionBtnPanel.GetComponent <Transform>())
            {
                if (obj.gameObject == actionBtnPanel)
                {
                    continue;
                }

                Destroy(obj.gameObject);
            }

            if (targetUIDContent.uiDialogActions != null)
            {
                for (int i = 0; i < targetUIDContent.uiDialogActions.Count; i++)
                {
                    GameObject newBtn     = Instantiate(actionBtn_Prefab, actionBtnPanel);
                    Button     newBtn_Btn = newBtn.GetComponentInChildren <Button>();

                    newBtn_Btn.onClick.AddListener(delegate { CloseDialog(); });
                    newBtn_Btn.onClick.AddListener(targetUIDContent.uiDialogActions[i].action);

                    TextMeshProUGUI newBtn_Text = newBtn.GetComponentInChildren <TextMeshProUGUI>();
                    newBtn_Text.text = targetUIDContent.uiDialogActions[i].buttonText;

                    Image newBtn_Img = newBtn.GetComponentInChildren <Image>();
                    if (
                        targetUIDContent.highlightBtn != 0 &&
                        targetUIDContent.uiDialogActions.Count >=
                        targetUIDContent.highlightBtn && i + 1 ==
                        targetUIDContent.highlightBtn)
                    {
                        newBtn_Img.color  = accentColor;
                        newBtn_Text.color = Color.white;
                    }
                }
            }

            if (targetUIDContent.showCloseDialogBtn)
            {
                closeDialogBtn.gameObject.SetActive(true);
            }
            else
            {
                closeDialogBtn.gameObject.SetActive(false);
            }
        }
Esempio n. 2
0
        // Pop up the prompt with parameters, prompt will be instantiated if not found
        public static void ShowDialog(
            string dialogTitleString,
            string dialogContentString,
            List <SimpleUIDialogAction> uiDialogActions = null,
            int highlightBtn    = 0,
            bool closeDialogBtn = true
            )
        {
            SimpleUIDialogContent dialogContent = new SimpleUIDialogContent
            {
                dialogTitleString   = dialogTitleString,
                dialogContentString = dialogContentString,
                uiDialogActions     = uiDialogActions,
                showCloseDialogBtn  = closeDialogBtn,
                highlightBtn        = highlightBtn,
            };

            Instance.uiDialogContentQueue.Enqueue(dialogContent);
        }