Skip to content
/ UMarkup Public

UMarkup is a simplified extension for Unity RichText Markup,It can enhance the text style of Log / UGUI Text / GUI Label, also for TextMeshPro.

License

Notifications You must be signed in to change notification settings

ls9512/UMarkup

Repository files navigation

UMarkup

UMarkup is a simplified extension for Unity RichText Markup,It can enhance the text style of Log / UGUI Text / GUI Label, also for TextMeshPro.

topLanguage size issue license last 996.icu

1. How to use

1.1. Common Styles

Use common styles in a concise way:

var str1 = "[Markup Test 1]"
	// <size=15><b><color=green>Complex Style</color></b></size>
	+ " Complex Style".Color(Color.green).Bold().Size(15)
	// <color=#ffffff>White</color>
	+ " White".Color(Color.white)
	// <i>Italics</i>
	+ " Italics".Italic()
	// <b>Bold</b>
	+ " Bold".Bold();
Debug.Log(str1);

1.2. Extension Method

Use extension methods to organize multiple different styles:

var str2 = "[Markup Test 2]"
	// <size=15><b><color=green>Complex Style</color></b></size>
	+ " Complex Style".ToMarkup(UMarkup.Green, UMarkup.Bold, UMarkup.Size(15))
	// <color=#ffffff>White</color>
	+ " White".ToMarkup(Color.white)
	// <i>Italics</i>
	+ " Italics".ToMarkup(UMarkup.Italic)
	// <b>Bold</b>
	+ " Bold".ToMarkup(UMarkup.Bold);
Debug.Log(str2);

1.3. Static Method

var str3 = "[Markup Test 3]"
	// <size=15><b><color=green>Complex Style</color></b></size>
	+ UMarkup.Create(" Complex Style", UMarkup.Green, UMarkup.Bold, UMarkup.Size(15))
	// <color=#ffffff>White</color>
	+ UMarkup.Create(" White", UMarkup.Color(Color.white))
	// <i>Italics</i>
	+ UMarkup.Create(" Italics", UMarkup.Italic)
	// <b>Bold</b>
	+ UMarkup.Create(" Bold", UMarkup.Bold);
Debug.Log(str3);

2. Supported Tags

2.1. Font Sytle

  • Size
  • Bold
  • Italic

2.2. Color Sytle

  • Red
  • Green
  • Blue
  • White
  • Blank
  • Yellow
  • Cyan
  • Magenta
  • Gray
  • Clear
  • Color

2.3. Other

  • Material
  • Quad

3. Custom Style

Support for custom extended styles can be obtained by creating a MarkupAdapter with custom parameters.

public static class MarkupCustomStyleSample
{
    // Custom single mark style
    public static MarkupAdapter CustomStyle1 { get; } = new MarkupAdapter("<singleMark>");

    // Custom left and right mark Style
    public static MarkupAdapter CustomStyle2 { get; } = new MarkupAdapter("<leftMark>", "</rightMark>");
}

4. Extension for TextMeshPro

You can also use UMarkup to build strings for TextMeshPro. The supported tag styles are as follows:

4.1. Supported Tags

  • AlignLeft
  • AlignCenter
  • AlignRight
  • Alpha
  • CharacterSpace
  • Font
  • Indentation
  • LineHeight
  • LineIndentation
  • Link
  • Lowercase
  • Uppercase
  • AllCaps
  • SmallCaps
  • Margin
  • Mark
  • MonoSpace
  • Noparse
  • NoBreakingSpaces
  • PageBreak
  • HorizontalPosition
  • Size
  • HorizontalSpace
  • Sprite
  • Underline
  • Strikethrough
  • Style
  • Superscript
  • Subscript
  • VerticalOffset
  • Width

4.2. Supported Size Formart

  • Pixels
  • FontUnits
  • Percentages

About

UMarkup is a simplified extension for Unity RichText Markup,It can enhance the text style of Log / UGUI Text / GUI Label, also for TextMeshPro.

Topics

Resources

License

Stars

Watchers

Forks

Languages