Esempio n. 1
0
        public void ShowDialog(DialogBoxData data)
        {
            _wasDialogShown = true;
            ResetAll();

            _data = data;

            if ((data == null) || (data.Message == null))
            {
                return;
            }

            // Show the dialog box
            _panel.Show();

            Text.text = data.Message;

            var buttonCount = 0;

            if (!string.IsNullOrEmpty(data.LeftButtonText))
            {
                // Setup Left button
                Button1.gameObject.SetActive(true);
                Button1.GetComponentInChildren <Text>().text = data.LeftButtonText;
                buttonCount++;
            }

            if (!string.IsNullOrEmpty(data.MiddleButtonText))
            {
                // Setup Middle button
                Button2.gameObject.SetActive(true);
                Button2.GetComponentInChildren <Text>().text = data.MiddleButtonText;
                buttonCount++;
            }

            if (!string.IsNullOrEmpty(data.RightButtonText))
            {
                // Setup Right button
                Button3.gameObject.SetActive(true);
                Button3.GetComponentInChildren <Text>().text = data.RightButtonText;
            }
            else if (buttonCount == 0)
            {
                // Add a default "Close" button if there are no other buttons in the dialog
                Button3.gameObject.SetActive(true);
                Button3.GetComponentInChildren <Text>().text = "Close";
            }

            Input.gameObject.SetActive(data.ShowInput);
            Input.text = data.DefaultInputText;


            transform.SetAsLastSibling();
        }
Esempio n. 2
0
        private void OnDialogEvent(DialogBoxData data)
        {
            if (_panel.IsVisible)
            {
                // We're already showing something
                // Display later by adding to queue
                _queue.Enqueue(data);
                return;
            }

            ShowDialog(data);
        }
Esempio n. 3
0
        public static DialogBoxData CreateTextInput(string message, Action <string> onComplete,
                                                    string rightButtonText = "OK")
        {
            var data = new DialogBoxData(message)
            {
                ShowInput       = true,
                RightButtonText = rightButtonText,
                InputAction     = onComplete,
                LeftButtonText  = "Close"
            };

            return(data);
        }
Esempio n. 4
0
        public static DialogBoxData CreateActionBox(string message, Action onClickLeft, Action onClickRight,
                                                    string leftButtonText, string rightButtonText = "Cancel")
        {
            var data = new DialogBoxData(message)
            {
                ShowInput         = false,
                RightButtonText   = rightButtonText,
                RightButtonAction = onClickRight,
                LeftButtonText    = leftButtonText,
                LeftButtonAction  = onClickLeft
            };

            return(data);
        }