AudioAsset
Ease
FastString
FontAsset
NineSlice
PackedSprite
PackedSpriteID
RB
   HardwareSettings
   IRetroBlitGame
RBAsset
Rect2i
ShaderAsset
SoundReference
SpriteGrid
SpriteSheetAsset
TMXMapAsset
   TMXLayer
   TMXLayerLoadState
   TMXObject
   TMXObjectGroup
   TMXProperties
Vector2i

RB.Print

Method  -  Static

public static void Print(Vector2i pos, Color32 color, string text)
public static void Print(Vector2i pos, Color32 color, int flags, string text)
public static void Print(Rect2i rect, Color32 color, int flags, string text)
public static void Print(Vector2i pos, Color32 color, FastString text)
public static void Print(Vector2i pos, Color32 color, int flags, FastString text)
public static void Print(Rect2i rect, Color32 color, int flags, FastString text)
public static void Print(FontAsset font, Vector2i pos, Color32 color, string text)
public static void Print(FontAsset font, Vector2i pos, Color32 color, int flags, string text)
public static void Print(FontAsset font, Rect2i rect, Color32 color, int flags, string text)
public static void Print(FontAsset font, Vector2i pos, Color32 color, FastString text)
public static void Print(FontAsset font, Vector2i pos, Color32 color, int flags, FastString text)
public static void Print(FontAsset font, Rect2i rect, Color32 color, int flags, FastString text)

Parameters

pos Vector2i Position
color Color32 Color
text string Text
flags int Optional flag RB.NO_INLINE_COLOR, and <see cref="cref="RB.NO_ESCAPE_CODES/>
rect Rect2i Rectangular area to print to
font FontAsset Font asset

Returns

Nothing.

Description

Print text to the display. The position of the text is specified by either pos or rect. When specifying position by rect the flags should also be specified to determine how the text should be aligned and clipped within the given rect.

Multiple flags can be combined together for the desired effect. The following text alignment flags are available:

The following clipping flags are available:

And these miscellaneous flags:

The font used is specified with font which corresponds to the font created with FontAsset.Setup. If no font is specified the RetroBlit built-in system font is used instead.

The color of the text is specified with the color parameter. This is only the starting color which can further be changed inline with the text content.

RetroBlit supports a variety of inline escape sequences to control the appearance of the text. The escape sequences are specified with the "@" character in the given text string. The following escape sequences are supported:

  • "@@" - Print @
  • "@######" - Color change in the format RRGGBB, where each color channel has a hex value between 00 and FF
  • "@-" - Revert back to the color specified in the color parameter.
  • "@w###" - Apply a wavy text effect in the format APS (wave amplitude, period, and speed), where each parameter has a value between 0 and 9. Default is "@w000"
  • "@s#" - Apply a shaky text effect in the format M (magnitude), where M has a value between 0 and 9. Default is "@s0"
  • "@g##" - Change the font to the given 2 digit font index. Default is "@g99" which is a special value indicating built-in system font. The new font must have the same glyph height as the previous font.

Example

void Render() {
    // Text string with the "damage" number in red
    var text = "Player hit for @FF0000" + damage + "@-!!!";

    // Manually align the text to the upper right corner of the screen with a 4 pixel offset
    var textSize = RB.PrintMeasure(text);
    var textPos = new Vector2i(RB.DisplaySize.width - text.width - 44);
    RB.Print(textPos, Color.white, text);

    // Automatically align text using a rect and alignment flags
    RB.Print(
        new Rect2i(00RB.DisplaySize.width, RB.DisplaySize.height),
        Color.white,
        RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER,
        text);
}

See Also

FontAsset
RB.PrintMeasure
RB.FontInlineIndexSetup

See Docs

Features - Fonts
SystemFont - Built-in System Font