ST Drawing Surface
An ST Drawing Surface is a synced surface to draw and paint on: a whiteboard, a canvas, a chalkboard, a graffiti wall. StageTime gives it a texture and shows it on a renderer. Lines drawn on any player's device reach everyone, and players who join later see everything drawn so far. Add it with Add Component → StageTime → ST Drawing Surface.
The surface is a 1 × 1 square in the GameObject's local X/Y plane, centred on it and seen from its −Z side, like a Unity Quad. Put it on a Quad, or on an empty GameObject placed and scaled to cover a board's front (a 2 × 1.2 m board: scale 2, 1.2, 1).
| Field | |
|---|---|
targetRenderer | The renderer that shows the drawing |
textureProperty | The material texture the drawing goes in: _BaseMap for URP Lit and Unlit |
materialIndex | Which of the renderer's materials shows it, for a model with several (a board and its frame). −1 = all |
width, height | Texture size in pixels, 64 to 2048. Match the surface's shape (2 × 1.2 m → 1280 × 768) |
background | The colour of a clear surface |
clearAccess | Who may clear it for everyone: everyone, or hosts and moderators |
| Member | |
|---|---|
DrawLine(from, to, width, color) | Draws a line for everyone. Positions go from (0, 0) at the bottom left to (1, 1) at the top right; width is in pixels |
DrawPoint(at, width, color) | Draws a dot for everyone |
Clear() | Clears it for everyone (if clearAccess allows) |
WorldToSurface(position) | Where a world position is on the surface: x and y (0 to 1 inside it), and z, the distance in metres in front of it (negative behind) |
texture | The drawing as a RenderTexture, for other materials or Graphics.Blit |
isFull | The surface has stored as much as it can; nothing more is drawn until it is cleared |
A pen
A pen is an ST Pickup that draws while its tip touches the surface. Only the holder's device draws; the surface sends the lines to everyone:
public class Pen : StageTimeBehaviour
{
public STDrawingSurface board;
public Transform tip;
public Color colour = Color.black;
private bool held, drawing;
private Vector2 last;
public override void OnPickup() => held = true;
public override void OnDrop() { held = false; drawing = false; }
private void Update()
{
if (!held) return;
Vector3 p = board.WorldToSurface(tip.position);
bool touching = p.z < 0.015f && p.z > -0.05f && p.x >= 0f && p.x <= 1f && p.y >= 0f && p.y <= 1f;
if (!touching) { drawing = false; return; }
var point = new Vector2(p.x, p.y);
if (!drawing) board.DrawPoint(point, 6f, colour);
else if ((point - last).sqrMagnitude > 0.000004f) board.DrawLine(last, point, 6f, colour);
else return;
last = point;
drawing = true;
}
}
Limits
- Each player can send up to 240 line segments a second, across all the world's surfaces; faster drawing is dropped.
- A surface keeps up to about 20,000 segments so it can send them to players who join later. When it is full,
isFullis true and nothing more is drawn until someone clears it. - Clearing is synced, at most once a second per player; there is no undo.
- A world's surfaces share 8 million pixels (two 2048 × 2048 surfaces). A surface that does not fit is made smaller, with a warning.