BBCode

Introduction

TextRuntime supports using BBCode-like syntax for formatting individual words and letters. Customizations include changing size, font, and even using custom functions.

Using BBCode for TextRuntimes supports all of the functionality outlined in the Text documentation which can be found here: https://docs.flatredball.com/gum/gum-tool/gum-elements/text/text#using-bbcode-for-inline-styling

Custom Functions

TextRuntime instances can use the Custom tag to define a custom function to be used when rendering a Text. This tag can be used to customize letters in a TextRuntime using custom code, allowing for effects such as wavy, rainbow, or shaking text.

The following variables can be modified on each letter. This list also includes their default values:

  • XOffset = 0

  • YOffset = 0

  • Color = null

  • ScaleX = 1

  • ScaleY = 1

  • RotationDegrees = 0

  • ReplacementCharacter = null

To use the Custom tag, the following must be performed:

  1. A function must be declared which is of the type Func<int, string, LetterCustomization>. The int value represents the index in the custom block, starting with 0. The string represents the entire string in the block. The returned LetterCustomization instance includes the desired modifications to the letter.

  2. This function must be registered with the RenderingLibrary.Graphics.Text type.

  3. A Custom tag must be included in the text string.

Code Example: Shaking Letters With Custom Tag

The following code block shows how to create a TextRuntime with letters shaking horizontally:

TextRuntime displaying shaking the word "cold"

Code Example: On-Command Custom Values

Custom tags can reference functions inside of classes which can provide additional customization, such as one-time changes.

The following code shows how to make text grow and shrink one time whenever gold is added. First, we create a class that includes the logic for growing/shrinking. This class also stores a StartTime variable which is used to determine the text size. Note that this is using a DateTime for simplicity, but you could also game time or other timing methods.

We can register this function and use it on a TextRuntime. The following code creates a button which increases the gold and resets the start time:

Button adding gold and resetting the grow shirnk time.

Last updated

Was this helpful?