Skip to content

Instantly share code, notes, and snippets.

@jfranmora
Last active June 26, 2022 13:52
Show Gist options
  • Select an option

  • Save jfranmora/1eea10afc3a8cd86b3e1a1f4dc7377d5 to your computer and use it in GitHub Desktop.

Select an option

Save jfranmora/1eea10afc3a8cd86b3e1a1f4dc7377d5 to your computer and use it in GitHub Desktop.
Extension class to use rich text in Unity Console. https://docs.unity3d.com/Manual/StyledText.html
public static class StringTagExt
{
public static string AddBoldTag(this string text)
{
return text.AddTag("b");
}
public static string AddItalicTag(this string text)
{
return text.AddTag("i");
}
public static string AddSizeTag(this string text, int size)
{
return text.AddTag("size", size);
}
public static string AddColorTag(this string text, string colorName)
{
return text.AddTag("color", colorName);
}
private static string AddTag(this string text, string tagName)
{
return $"<{tagName}>{text}</{tagName}>";
}
private static string AddTag(this string text, string tagName, object value1)
{
return $"<{tagName}=\"{value1}\">{text}</{tagName}>";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment