Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class HighlightKeywords: MonoBehaviour
{
void OnConversationLine(Subtitle subtitle)
{
// Make the word "quest" wiggle:
subtitle.formattedText.text = subtitle.formattedText.text.Replace("quest", "<wiggle>quest</wiggle>");
}
}
Code: Select all
using System.Text.RegularExpressions;
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class HighlightKeywords: MonoBehaviour
{
void OnConversationLine(Subtitle subtitle)
{
subtitle.formattedText.text = Regex.Replace(
subtitle.formattedText.text,
@"\bquest\b",
match =>
{
return $"<wiggle>{match.Value}</wiggle>";
});
}
}