/// <summary>
        /// Unsubscribe from EventHandler's dialogue advancement callbacks.
        /// </summary>
        private void UnsubscribeFromEventHandler(DialogueParagraph paragraph)
        {
            // Unsubscribe from callbacks.
            paragraph.EventHandler.RemoveListener(this);

            // Notify EventHandler that it is currently being unloaded.
            paragraph.EventHandler.OnUnload();
        }
        /// <summary>
        /// Subscribe to EventHandler's dialogue advancement callbacks.
        /// </summary>
        private void SubscribeToEventHandler(DialogueParagraph paragraph)
        {
            // Subscribe to callbacks.
            paragraph.EventHandler.AddListener(this);

            // Notify EventHandler that it is currently being loaded.
            paragraph.EventHandler.OnLoad();
        }
        private IEnumerator PrintRoutine(DialogueParagraph paragraph)
        {
            // Print the first character instantly.
            float charactersToPrint = 1;
            int   charactersPrinted = 0;

            // Clear existing text.
            _bodyText.text = string.Empty;

            while (charactersPrinted < paragraph.Text.Length)
            {
                charactersToPrint += Time.deltaTime * paragraph.PrintSpeed;
                for (int i = Mathf.FloorToInt(charactersToPrint); i > 0; i--)
                {
                    if (charactersPrinted < paragraph.Text.Length)
                    {
                        _bodyText.text += paragraph.Text[charactersPrinted];
                        charactersPrinted++;
                        charactersToPrint--;
                    }
                    else
                    {
                        // All characters printed, so wait default delay and then finish.
                        yield return(new WaitForSecondsRealtime(1f / paragraph.PrintSpeed));

                        CurrentParagraph.EventHandler.OnFinishPrinting();
                        yield break;
                    }
                }

                yield return(new WaitForSecondsRealtime(1f / paragraph.PrintSpeed));
            }

            CurrentParagraph.EventHandler.OnFinishPrinting();
            yield break;
        }
 /// <summary>
 /// Informs the ParagraphEventHandler to what DialogueParagraph it is attached.
 /// </summary>
 public void AssignParagraph(DialogueParagraph targetParagraph)
 {
     _targetParagraph = targetParagraph;
 }
 /// <summary>
 /// Starts a coroutine that prints the current paragraph.
 /// </summary>
 private void StartPrinting(DialogueParagraph paragraph)
 {
     SetSpeaker(paragraph.Speaker);
     paragraph.EventHandler.OnStartPrinting();
     _printRoutine = StartCoroutine(PrintRoutine(paragraph));
 }