/// <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);
        }
 protected virtual void Awake()
 {
     canvas     = GetComponentInChildren <Canvas>();
     animator   = GetComponentInChildren <Animator>();
     typewriter = TypewriterUtility.GetTypewriter(barkText);
     if ((animator == null) && (canvasGroup != null))
     {
         animator = canvasGroup.GetComponentInChildren <Animator>();
     }
 }
        protected virtual IEnumerator StartTypingWhenFocused(UITextField subtitleText, string text, int fromIndex)
        {
            subtitleText.text = string.Empty;
            float timeout = Time.realtimeSinceStartup + 5f;

            while (!hasFocus && panelState != PanelState.Open && Time.realtimeSinceStartup < timeout)
            {
                yield return(null);
            }
            subtitleText.text = text;
            TypewriterUtility.StartTyping(subtitleText, text, fromIndex);
        }
Exemple #4
0
 public virtual void SetTypewriterSpeed(float charactersPerSecond)
 {
     for (int i = 0; i < m_builtinPanels.Count; i++)
     {
         if (m_builtinPanels[i] != null)
         {
             TypewriterUtility.GetTypewriterSpeed(m_builtinPanels[i].subtitleText);
         }
     }
     if (m_defaultNPCPanel != null && !m_builtinPanels.Contains(m_defaultNPCPanel))
     {
         TypewriterUtility.GetTypewriterSpeed(m_defaultNPCPanel.subtitleText);
     }
     if (m_defaultPCPanel != null && !m_builtinPanels.Contains(m_defaultPCPanel))
     {
         TypewriterUtility.GetTypewriterSpeed(m_defaultPCPanel.subtitleText);
     }
 }
Exemple #5
0
        public virtual float GetTypewriterSpeed()
        {
            AbstractTypewriterEffect typewriter;

            for (int i = 0; i < m_builtinPanels.Count; i++)
            {
                typewriter = GetTypewriter(m_builtinPanels[i]);
                if (typewriter != null)
                {
                    return(TypewriterUtility.GetTypewriterSpeed(typewriter));
                }
            }
            typewriter = GetTypewriter(m_defaultNPCPanel);
            if (typewriter != null)
            {
                return(TypewriterUtility.GetTypewriterSpeed(typewriter));
            }
            typewriter = GetTypewriter(m_defaultNPCPanel);
            return(TypewriterUtility.GetTypewriterSpeed(typewriter));
        }
Exemple #6
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;
        }
 /// <summary>
 /// Sets the speed of the typewriter effect on the subtitle element if it has one.
 /// </summary>
 public void SetTypewriterSpeed(float charactersPerSecond)
 {
     TypewriterUtility.SetTypewriterSpeed(subtitleText, charactersPerSecond);
 }
 /// <summary>
 /// Returns the speed of the typewriter effect on the subtitle element if it has one.
 /// </summary>
 public float GetTypewriterSpeed()
 {
     return(TypewriterUtility.GetTypewriterSpeed(subtitleText));
 }
 /// <summary>
 /// Returns the typewriter effect on the subtitle text element, or null if there is none.
 /// </summary>
 public AbstractTypewriterEffect GetTypewriter()
 {
     return(TypewriterUtility.GetTypewriter(subtitleText));
 }
Exemple #10
0
 private AbstractTypewriterEffect GetTypewriter(StandardUISubtitlePanel panel)
 {
     return((panel != null) ? TypewriterUtility.GetTypewriter(panel.subtitleText) : null);
 }