Exemple #1
0
        /// <summary>
        /// Opens dialog, waits for input, then closes
        /// </summary>
        /// <returns></returns>
        protected IEnumerator RunDialogOverTime()
        {
            // Create our buttons and set up our message
            GenerateButtons();
            SetTitleAndMessage();
            FinalizeLayout();
            // Register all active buttons under buttonParent as interactibles
            foreach (Transform button in buttonParent)
            {
                if (button.gameObject.activeSelf)
                {
                    SimpleDialogButton sdb = button.gameObject.GetComponent <SimpleDialogButton>();
                    if (sdb == null)
                    {
                        UnityEngine.Debug.LogError("No 'SimpleDialogButton' component attached to dialog button!");
                    }
                    Registerinteractable(button.gameObject);
                }
            }

            // Open dialog
            state = StateEnum.Opening;
            yield return(StartCoroutine(OpenDialog()));

            state = StateEnum.WaitingForInput;
            // Wait for input
            while (state == StateEnum.WaitingForInput)
            {
                UpdateDialog();
                yield return(null);
            }
            // Close dialog
            state = StateEnum.Closing;
            yield return(StartCoroutine(CloseDialog()));

            state = StateEnum.Closed;
            // Callback
            if (OnClosed != null)
            {
                OnClosed(result);
            }
            // Wait a moment to give scripts a chance to respond
            yield return(null);

            // Destroy ourselves
            GameObject.Destroy(gameObject);
            yield break;
        }
Exemple #2
0
        protected override void InputDown(GameObject obj, InputEventData eventData)
        {
            base.InputDown(obj, eventData);
            // If we're not done opening, wait
            if (state != StateEnum.WaitingForInput)
            {
                return;
            }

            SimpleDialogButton button = obj.GetComponent <SimpleDialogButton>();

            // If this isn't a simple dialog button it's not our problem
            if (button == null)
            {
                return;
            }

            result.Result = button.Type;
            state         = StateEnum.Closing;
        }