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

FastString.Set

Method

public FastString Set(string str, int startIndex = 0, int len = int.MaxValue)
public FastString Set(FastString str, int startIndex = 0, int len = int.MaxValue)
public FastString Set(char c)
public FastString Set(long val, uint minDigits = 0, uint flags = 0)
public FastString Set(ulong val, uint minDigits = 0, uint flags = 0)
public FastString Set(int val, uint minDigits = 0, uint flags = 0)
public FastString Set(uint val, uint minDigits = 0, uint flags = 0)
public FastString Set(short val, uint minDigits = 0, uint flags = 0)
public FastString Set(ushort val, uint minDigits = 0, uint flags = 0)
public FastString Set(sbyte val, uint minDigits = 0, uint flags = 0)
public FastString Set(byte val, uint minDigits = 0, uint flags = 0)
public FastString Set(float val, uint precision = PRECISION_UNDEFINED)
public FastString Set(double val, uint precision = PRECISION_UNDEFINED)
public FastString Set(Vector2i val)
public FastString Set(Vector2 val)
public FastString Set(Vector3 val)
public FastString Set(Vector4 val)
public FastString Set(Rect2i val)
public FastString Set(Rect val)
public FastString Set(Color32 val, uint flags = 0)
public FastString Set(Color val, uint flags = 0)

Parameters

str string Source string
startIndex int Start index, default 0
len int Length, defaults to end of string
c char Char
val long Value
minDigits uint Minimum digits
flags uint One of FastString.FILL_SPACES or FastString.FILL_ZEROS
precision uint Decimal precision

Returns

FastString

The same instance of FastString

Description

Sets a value of the string. Many different kinds of values can be set, including strings, numbers, vectors, rects, and colors.

When setting to a string or another FastString a substring can be specified using the startIndex and len parameters.

When setting to numbers, minDigits specify the minimum amount of digits that should be added, with padding added as necessary. Padding type is specified with flags, which can be either FastString.FILL_SPACES, or FastString.FILL_ZEROS.

When setting to floating point numbers the decimal point precision can be specified with precision, the default value is FastString.PRECISION_UNDEFINED.

The FastString.Set method returns this, which allows it to be chained with other FastString methods such as FastString.Append.

This is equivalent of calling FastString.Clear followed by FastString.Append.

Example

// Allocate a FastString that can hold up to 256 characters
FastString fstr = new FastString(256);

void Render() {
    fstr.Set("Hello there ").Append(playerName).Append("!");
    RB.Print(new Vector2i(00), Color.white, fstr);
}

See Also

FastString.Clear
FastString.Truncate

See Docs

Features - Avoid GC with Fast String