Lines, Trails and World Text
Three built-in components draw flat shapes in the 3D world. A Line Renderer draws a ribbon through a list of points, a Trail Renderer records where its node has been and fades that path away, and World Text draws a label that sits in the scene and can face the camera. All three are in the Add Component menu under Rendering, and they are drawn by the same world graphics pass in Studio's views and in exported games.
Line Renderer
A LineRenderer is a textured ribbon along a polyline. Its width and colour change along the line, and it can face the camera or keep an authored direction.
| Property | Default | Meaning |
|---|---|---|
Positions |
empty | The polyline points. Assigning the list copies it. |
UseWorldSpace |
true |
Whether the points are world coordinates. When false, the node's full transform places the ribbon. |
Billboard |
true |
Whether the ribbon turns to face each rendering camera. |
Normal |
Vector3.UnitZ |
The facing direction, in the points' coordinate space, used when Billboard is false. |
WidthCurve |
width 1 | A FloatCurve of non-negative widths along the line. |
ColorGradient |
white | A ColorGradient of linear RGBA colours along the line. |
TextureMode |
Stretch |
Stretch maps the texture once along the whole line. Tile repeats it once per unit of length. |
Texture |
none | An optional TextureAsset, multiplied into the gradient. Empty draws a solid colour. |
WidthCurve and ColorGradient are sampled by normalized distance along the line, from 0 at the first point to 1 at the last. Their keys must have distinct, increasing times between 0 and 1; beyond the first and last key the value is clamped. Build them from CurveKey(time, width) and GradientKey(time, color):
line.WidthCurve = new FloatCurve { Keys = [new CurveKey(0, 0.05f), new CurveKey(1, 0.2f)] };
line.ColorGradient = new ColorGradient { Keys = [new GradientKey(0, Color.Yellow), new GradientKey(1, Color.Red with { A = 0f })] };
Trail Renderer
A TrailRenderer derives from LineRenderer, so width, colour, texture and billboarding work the same way. Instead of authored points it records the world position of its own node once per frame and keeps the recent history as the ribbon.
| Property | Default | Meaning |
|---|---|---|
Time |
1 |
How long a recorded point lives, in simulation seconds. Must be positive. |
MinVertexDistance |
0.1 |
The distance the node must move before another point is recorded. |
Emitting |
true |
Whether movement records new points. Existing points keep ageing when it is false. |
MaxPoints |
4096 |
The most points kept at once. Bounds memory when the node moves very fast. |
PositionCount |
read-only | The number of live points. |
Along a trail, WidthCurve and ColorGradient run from 0 at the newest point to 1 at the point that has expired. Clear() empties the history at once, and disabling the component clears it too. Trail history is not written to saves.
World Text
A WorldTextComponent draws a label in world space, using a signed-distance-field rendering of the font so edges stay smooth when the label is scaled.
| Property | Default | Meaning |
|---|---|---|
Text |
"Text" |
The text to draw. A newline starts a new line; an empty string draws nothing. |
Font |
"sans-serif" |
A Skia font family, a project font path, or an asset:// font identifier. Fonts are shared with the runtime UI, as in Game UI. |
FontSize |
0.5 |
The em height in world units, before the node's scale. Must be positive. |
Color |
white | A linear RGBA tint. Lower the alpha to fade a label out. |
Billboard |
true |
Whether each camera sees the front of the label. When false, the node's orientation is kept. |
Anchor |
(0.5, 0.5) |
The point of the label placed at the node, from the lower-left corner in normalized units. The default centres it. |
Changing Text or Font regenerates the glyphs; changing only the transform or colour does not. A label whose rendered text is larger than 4096 pixels on either side is rejected, so split long text into several lines or several labels.
Drawing order
Lines, trails and text are transparent. They are tested against the opaque scene, so walls and props hide them, but they do not write depth. The renderer sorts them back to front by distance from the camera, measured from each shape's centre. Two transparent shapes that intersect each other can therefore blend in the wrong order.
Minimal example
This script sets up a line and a score label on one node. Add it to a node in the scene, then:
- Add a Line Renderer component to the same node (Add Component → Rendering → Line Renderer).
- Create a child node and add a World Text component to it.
- Drop the child's
WorldTextComponenton the script's Label field. - Press Play: a yellow line fades to transparent above the node, and the label reads "Beacon 0".
namespace Usercode;
public class Beacon : Component
{
public WorldTextComponent? Label;
public override void OnStart()
{
var line = Node!.GetComponent<LineRenderer>();
if (line is not null)
{
line.UseWorldSpace = false;
line.Positions = [Vector3.Zero, Vector3.UnitY * 3f];
line.WidthCurve = new FloatCurve { Keys = [new CurveKey(0, 0.05f), new CurveKey(1, 0.05f)] };
line.ColorGradient = new ColorGradient { Keys = [new GradientKey(0, Color.Yellow), new GradientKey(1, Color.Red with { A = 0f })] };
}
SetScore(0);
}
public void SetScore(int value)
{
if (Label is not null)
{
Label.Text = $"Beacon {value}";
}
}
}
UseWorldSpace = false makes the points relative to the node, so the line moves with it. Call SetScore from any other script that knows the value changed; the label only regenerates when the text actually changes.
Gotchas
- The
Positionslist is copied on assignment. Changing the array you passed in has no effect; assign a new list instead. - Widths must be non-negative and colour values must be finite;
FloatCurveandColorGradientthrow when their keys are set with invalid values. - A
TrailRendererrecords its node's position inOnLateUpdate, after the scripts have moved the node inOnUpdate, so the trail never lags a frame behind a script that moves its node.
Next steps
- Components — how to write the scripts used above, and the lifecycle callbacks.
- Rendering — the frame, cameras and lights.
- Game UI — screen-space menus and HUDs, for text that should not live in the world.