Table of Contents

Class RichText

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

Utility class for formatting rich text strings with color, size, and optional prefixes/suffixes for UI display. Provides both string-returning Format methods and zero-allocation AppendTo methods for StringBuilder use.

public static class RichText
Inheritance
RichText
Inherited Members

Methods

AppendTo(ref Utf16ValueStringBuilder, string, bool, string, string)

Appends a formatted string value with optional color, size, and line break directly to an existing string builder. Avoids intermediate string allocations when building composite tooltips.

public static void AppendTo(ref Utf16ValueStringBuilder sb, string value, bool appendLine = false, string hexColor = null, string size = null)

Parameters

sb Utf16ValueStringBuilder

The string builder to append to.

value string

The string value to display.

appendLine bool

If true, adds a line break before the value.

hexColor string

Hex color code for the value text.

size string

Font size for the value text.

AppendTo(ref Utf16ValueStringBuilder, string, float, bool, string, string, string, string)

Appends a formatted float value with optional name, color, size, prefix, and suffix directly to an existing string builder. Avoids intermediate string allocations when building composite tooltips.

public static void AppendTo(ref Utf16ValueStringBuilder sb, string valueName, float value, bool appendLine = false, string hexColor = null, string appendPrefix = null, string appendSuffix = null, string size = null)

Parameters

sb Utf16ValueStringBuilder

The string builder to append to.

valueName string

Label for the value (e.g., "Health").

value float

The float value to display.

appendLine bool

If true, adds a line break before the value.

hexColor string

Hex color code for the value text.

appendPrefix string

Optional prefix to add before the value.

appendSuffix string

Optional suffix to add after the value.

size string

Font size for the value text.

Format(string, bool, string, string)

Formats a string value with optional color, size, and line break for rich text display. Returns an empty string if value is null or whitespace.

public static string Format(string value, bool appendLine = false, string hexColor = null, string size = null)

Parameters

value string

The string value to display.

appendLine bool

If true, adds a line break before the value.

hexColor string

Hex color code for the value text.

size string

Font size for the value text.

Returns

string

Formatted rich text string.

Format(string, float, bool, string, string, string, string)

Formats a float value with optional name, color, size, prefix, and suffix for rich text display. Returns an empty string if value is zero.

public static string Format(string valueName, float value, bool appendLine = false, string hexColor = null, string appendPrefix = null, string appendSuffix = null, string size = null)

Parameters

valueName string

Label for the value (e.g., "Health").

value float

The float value to display.

appendLine bool

If true, adds a line break before the value.

hexColor string

Hex color code for the value text.

appendPrefix string

Optional prefix to add before the value.

appendSuffix string

Optional suffix to add after the value.

size string

Font size for the value text.

Returns

string

Formatted rich text string.