Accumulate Text reaching limit causes greyed out effect to disappear
Posted: Fri Nov 24, 2023 2:33 pm
Hi,
I'm using the scrolling dialogue UI in combination with this greyed out text code:
but when the accumulated text reaches the maximum number of lines, the greyed out effect disappears? The individual conversations are quite long so I can't just raise the max lines amount otherwise it starts to lag pretty bad.
Thanks.
I'm using the scrolling dialogue UI in combination with this greyed out text code:
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
using System.Text.RegularExpressions;
public class GrayAccumulatedText : MonoBehaviour
{
public Color oldTextColor = Color.gray;
public void OnConversationLine(Subtitle subtitle)
{
if (string.IsNullOrEmpty(subtitle.formattedText.text)) return;
SetAccumulatedTextGray();
}
private void SetAccumulatedTextGray()
{
var subtitlePanel = DialogueManager.standardDialogueUI.conversationUIElements.defaultNPCSubtitlePanel;
// Remove color tags from old accumulated text:
const string pattern = @"<color=[#]?\w+>|</color>";
subtitlePanel.accumulatedText = Regex.Replace(subtitlePanel.accumulatedText, pattern, string.Empty);
// Wrap accumulated text in gray:
subtitlePanel.accumulatedText = UITools.WrapTextInColor(subtitlePanel.accumulatedText, oldTextColor);
}
}
Thanks.