Skip to content

DebugDraw

namespace Griff.Runtime;
public sealed class DebugDraw

Draws lines, boxes, circles and text over the game for one frame, to see what code is thinking: a raycast, an enemy’s sight range, a path. Call it every frame you want the shape shown (from Update), or pass seconds to keep it up that long. Shapes are drawn over everything, with lines the same thickness however far the camera zooms.

public bool Enabled { get; set; }

Set to false to stop drawing debug shapes (they’re still accepted, just not shown), e.g. for a release build.

public IEnumerable<DebugShape> Shapes { get; }

The shapes to draw this frame.

public void Box(Box box, Color? color = default, float seconds = 0f)

The outline of box, e.g. a collider’s Physics.BoundsOf.

public void Box(Vector2 center, Vector2 size, Color? color = default, float seconds = 0f)

The outline of a box of size centered on center.

public void Circle(Vector2 center, float radius, Color? color = default, float seconds = 0f)

The outline of a circle.

public void Circle(Vector3 center, float radius, Color? color = default, float seconds = 0f)

The outline of a circle; Z is ignored.

public void Clear()

Forgets every shape, including ones meant to last longer.

public void Line(Vector2 from, Vector2 to, Color? color = default, float seconds = 0f)

A line from from to to.

public void Line(Vector3 from, Vector3 to, Color? color = default, float seconds = 0f)

A line from from to to; Z is ignored.

public void Path(IEnumerable<Vector2> points, Color? color = default, float seconds = 0f)

Lines joining points in order, e.g. a path from FindPath.

public void Point(Vector2 point, Color? color = default, float seconds = 0f, float size = 0.2f)

A small cross marking point.

public void Ray(Vector2 origin, Vector2 direction, Color? color = default, float seconds = 0f)

A line from origin going direction (its length is the line’s length).

public void Text(Vector2 position, object? text, Color? color = default, float seconds = 0f, float size = 0.5f)

A line of text centered on position, size world units high.

public void Text(Vector3 position, object? text, Color? color = default, float seconds = 0f, float size = 0.5f)

A line of text centered on position; Z is ignored.

public static readonly Color DefaultColor

The color used when none is given.