コード例 #1
0
        /// <summary>
        /// Sets the content of the panel. Assumes the panel is already open.
        /// </summary>
        public virtual void SetContent(Subtitle subtitle)
        {
            if (subtitle == null)
            {
                return;
            }
            currentSubtitle = subtitle;
            if (!onlyShowNPCPortraits || subtitle.speakerInfo.isNPC)
            {
                if (portraitImage != null)
                {
                    portraitImage.sprite = UITools.CreateSprite(subtitle.GetSpeakerPortrait());
                }
                portraitName.text = subtitle.speakerInfo.Name;
                UITools.SendTextChangeMessage(portraitName);
            }
            TypewriterUtility.StopTyping(subtitleText);
            var previousText = accumulateText ? m_accumulatedText : string.Empty;

            SetFormattedText(subtitleText, previousText, subtitle.formattedText);
            if (accumulateText)
            {
                m_accumulatedText = subtitleText.text + "\n";
            }
            TypewriterUtility.StartTyping(subtitleText, subtitleText.text, previousText.Length);
        }
コード例 #2
0
 /// <summary>
 /// Sets a label with formatted text.
 /// </summary>
 /// <param name='label'>
 /// Label to set.
 /// </param>
 /// <param name='formattedText'>
 /// Formatted text.
 /// </param>
 private void SetFormattedText(UnityEngine.UI.Text label, FormattedText formattedText)
 {
     if (label != null)
     {
         if (formattedText != null)
         {
             var text = UITools.GetUIFormattedText(formattedText);
             if (ignorePauseCodes)
             {
                 text = UnityUITypewriterEffect.StripRPGMakerCodes(text);
             }
             label.text = text;
             UITools.SendTextChangeMessage(label);
             if (!haveSavedOriginalColor)
             {
                 originalColor          = label.color;
                 haveSavedOriginalColor = true;
             }
             label.color = (formattedText.emphases.Length > 0) ? formattedText.emphases[0].color : originalColor;
         }
         else
         {
             label.text = string.Empty;
         }
     }
 }
コード例 #3
0
 protected void SetFormattedText(UITextField textField, string previousText, FormattedText formattedText)
 {
     textField.text = previousText + UITools.GetUIFormattedText(formattedText);
     UITools.SendTextChangeMessage(textField);
     if (!haveSavedOriginalColor)
     {
         originalColor          = textField.color;
         haveSavedOriginalColor = true;
     }
     textField.color = (formattedText.emphases.Length > 0) ? formattedText.emphases[0].color : originalColor;
 }
コード例 #4
0
 /// <summary>
 /// Sets the subtitle.
 /// </summary>
 /// <param name='subtitle'>
 /// Subtitle.
 /// </param>
 public override void SetSubtitle(Subtitle subtitle)
 {
     if ((subtitle != null) && !string.IsNullOrEmpty(subtitle.formattedText.text))
     {
         if (portraitImage != null)
         {
             portraitImage.sprite = UITools.CreateSprite(subtitle.GetSpeakerPortrait());
         }
         if (portraitName != null)
         {
             portraitName.text = subtitle.speakerInfo.Name;
             UITools.SendTextChangeMessage(portraitName);
         }
         if (line != null)
         {
             var typewriterEffect = line.GetComponent <UnityUITypewriterEffect>();
             if (typewriterEffect != null && typewriterEffect.enabled)
             {
                 typewriterEffect.Stop();
                 typewriterEffect.playOnEnable = false;
             }
             SetFormattedText(line, subtitle.formattedText);
             //---Was: if (typewriterEffect != null && typewriterEffect.enabled) typewriterEffect.OnEnable();
             //---Now manually start Play for more precise control.
             if (typewriterEffect != null && typewriterEffect.enabled)
             {
                 typewriterEffect.PlayText(subtitle.formattedText.text);
             }
         }
         Show();
         if (alwaysVisible && line != null)
         {
             var typewriterEffect = line.GetComponent <UnityUITypewriterEffect>();
             if (typewriterEffect != null)
             {
                 typewriterEffect.OnEnable();
             }
         }
     }
     else
     {
         if ((line != null) && (subtitle != null))
         {
             SetFormattedText(line, subtitle.formattedText);
         }
         Hide();
     }
 }
コード例 #5
0
        /// <summary>
        /// Sets the content of the panel. Assumes the panel is already open.
        /// </summary>
        public virtual void SetContent(Subtitle subtitle)
        {
            if (subtitle == null)
            {
                return;
            }
            currentSubtitle = subtitle;
            CheckSubtitleAnimator(subtitle);
            if (!onlyShowNPCPortraits || subtitle.speakerInfo.isNPC)
            {
                if (portraitImage != null)
                {
                    var sprite = subtitle.GetSpeakerPortrait();
                    portraitImage.sprite = sprite;
                    Tools.SetGameObjectActive(portraitImage, sprite != null);
                }
                portraitActorName = subtitle.speakerInfo.nameInDatabase;
                portraitName.text = subtitle.speakerInfo.Name;
                UITools.SendTextChangeMessage(portraitName);
            }
            TypewriterUtility.StopTyping(subtitleText);
            var previousText  = accumulateText ? m_accumulatedText : string.Empty;
            var previousChars = accumulateText ? UITools.StripRPGMakerCodes(Tools.StripTextMeshProTags(Tools.StripRichTextCodes(previousText))).Length : 0;

            SetFormattedText(subtitleText, previousText, subtitle.formattedText);
            if (accumulateText)
            {
                m_accumulatedText = subtitleText.text + "\n";
            }
            if (delayTypewriterUntilOpen && !hasFocus)
            {
                StartCoroutine(StartTypingWhenFocused(subtitleText, subtitleText.text, previousChars));
            }
            else
            {
                TypewriterUtility.StartTyping(subtitleText, subtitleText.text, previousChars);
            }
            frameLastSetContent = Time.frameCount;
        }
コード例 #6
0
 /// <summary>
 /// Sets the subtitle.
 /// </summary>
 /// <param name='subtitle'>
 /// Subtitle.
 /// </param>
 public override void SetSubtitle(Subtitle subtitle)
 {
     if ((subtitle != null) && !string.IsNullOrEmpty(subtitle.formattedText.text))
     {
         if (portraitImage != null)
         {
             portraitImage.sprite = subtitle.GetSpeakerPortrait();
         }
         if (portraitName != null)
         {
             portraitName.text = subtitle.speakerInfo.Name;
             UITools.SendTextChangeMessage(portraitName);
         }
         if (line != null)
         {
             var typewriterEffect = line.GetComponent <UnityUITypewriterEffect>();
             if (typewriterEffect != null && typewriterEffect.enabled)
             {
                 typewriterEffect.Stop();
                 typewriterEffect.playOnEnable = false;
             }
             SetFormattedText(line, subtitle.formattedText);
             if (typewriterEffect != null && typewriterEffect.enabled)
             {
                 typewriterEffect.PlayText(subtitle.formattedText.text);
             }
         }
     }
     else
     {
         if ((line != null) && (subtitle != null))
         {
             SetFormattedText(line, subtitle.formattedText);
         }
     }
 }