UMarkup is a simplified extension for Unity RichText Markup,It can enhance the text style of Log / UGUI Text / GUI Label, also for TextMeshPro.
-
- 1.1. Common Styles
- 1.2. Extension Method
- 1.3. Static Method
-
- 2.1. Font Sytle
- 2.2. Color Sytle
- 2.3. Other
-
- 4.1. Supported Tags
- 4.2. Supported Size Formart
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);
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);
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);
- Size
- Bold
- Italic
- Red
- Green
- Blue
- White
- Blank
- Yellow
- Cyan
- Magenta
- Gray
- Clear
- Color
- Material
- Quad
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>");
}
You can also use UMarkup to build strings for TextMeshPro. The supported tag styles are as follows:
- 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
- Pixels
- FontUnits
- Percentages