/// <summary>
 /// Barks a subtitle. Does not observe formatting codes in the subtitle's FormattedText,
 /// instead using the formatting settings defined on this component.
 /// </summary>
 /// <param name='subtitle'>
 /// Subtitle to bark.
 /// </param>
 public override void Bark(Subtitle subtitle)
 {
     if (ShouldShowText(subtitle))
     {
         SetUIElementsActive(false);
         string subtitleText = subtitle.formattedText.text;
         if (includeName)
         {
             if (nameText != null)
             {
                 nameText.text = subtitle.speakerInfo.Name;
             }
             else
             {
                 subtitleText = string.Format("{0}: {1}", subtitleText, subtitle.formattedText.text);
             }
         }
         if (barkText != null)
         {
             barkText.text = subtitleText;
         }
         SetUIElementsActive(true);
         if (CanTriggerAnimations() && !string.IsNullOrEmpty(animationTransitions.showTrigger))
         {
             animator.SetTrigger(animationTransitions.showTrigger);
         }
         CancelInvoke("Hide");
         var barkDuration = Mathf.Approximately(0, duration) ? DialogueManager.GetBarkDuration(subtitleText) : duration;
         if (!(waitUntilSequenceEnds || waitForContinueButton))
         {
             Invoke("Hide", barkDuration);
         }
         doneTime = DialogueTime.time + barkDuration;
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Barks a subtitle. Does not observe formatting codes in the subtitle's FormattedText,
        /// instead using the formatting settings defined on this component.
        /// </summary>
        /// <param name='subtitle'>
        /// Subtitle to bark.
        /// </param>
        public override void Bark(Subtitle subtitle)
        {
            if (ShouldShowText(subtitle))
            {
                SetUIElementsActive(false);
                string subtitleText = subtitle.formattedText.text;
                if (includeName)
                {
                    if (nameText != null)
                    {
                        nameText.text = subtitle.speakerInfo.Name;
                    }
                    else
                    {
                        subtitleText = string.Format("{0}: {1}", subtitleText, subtitle.formattedText.text);
                    }
                }
                else
                {
                    if (nameText != null && nameText.gameObject != null)
                    {
                        nameText.gameObject.SetActive(false);
                    }
                }
                if (showPortraitImage && subtitle.speakerInfo.portrait != null)
                {
                    Tools.SetGameObjectActive(portraitImage, true);
                    portraitImage.sprite = subtitle.speakerInfo.portrait;
                }
                else
                {
                    Tools.SetGameObjectActive(portraitImage, false);
                }
                if (barkText != null)
                {
                    barkText.text = subtitleText;
                }

                SetUIElementsActive(true);
                if (CanTriggerAnimations() && !string.IsNullOrEmpty(animationTransitions.showTrigger))
                {
                    animator.SetTrigger(animationTransitions.showTrigger);
                }
                if (typewriter != null)
                {
                    typewriter.StartTyping(subtitleText);
                }

                //--- We now observe DialogueTime.time instead of using Invoke.
                //CancelInvoke("Hide");
                var barkDuration = Mathf.Approximately(0, duration) ? DialogueManager.GetBarkDuration(subtitleText) : duration;
                //if (!(waitUntilSequenceEnds || waitForContinueButton)) Invoke("Hide", barkDuration);
                if (waitUntilSequenceEnds)
                {
                    numSequencesActive++;
                }
                doneTime = waitForContinueButton ? Mathf.Infinity : (DialogueTime.time + barkDuration);
            }
        }