Table of Contents

Debug Shapes

Immediate-mode wireframe and solid shapes for debugging: colliders, ray hits, spawn points, the direction something is facing. They ship in the Stride.CommunityToolkit.DebugShapes package.

Getting the system

Register the renderer once with AddDebugShapes(), then resolve ImmediateDebugRenderSystem from the game's services. It is registered as a service and as a game system, so you get it the same way from a script or from a code-only Start callback.

game.AddDebugShapes();

var debugDraw = game.Services.GetService<ImmediateDebugRenderSystem>();
Important

This is immediate mode: a shape is drawn for the frame you asked for it and then forgotten. Call the Draw* methods from your update loop, not once at startup. duration is how many extra seconds the shape survives without being re-issued; leave it at 0 for the once-per-frame case.

AddDebugShapes() turns Visible on only when the toolkit itself is a Debug build. With the published package, set Visible = true on the system, or nothing appears.

Shared parameters

Every method below ends with the same optional parameters, so they are listed once here rather than repeated:

Parameter Default Meaning
color default (null on DrawLines) The shape's colour.
duration 0.0f Seconds the shape stays visible without being re-issued. 0 means this frame only.
depthTest true When false, the shape draws through geometry in front of it.
solid false Filled instead of wireframe. Not available on the line methods.

Shapes

Method Shape-specific parameters
DrawLine start, end - no solid
DrawLines vertices - an array drawn as a connected run. No solid
DrawRay start, dir - a direction rather than an end point. No solid
DrawArrow from, to, coneHeight, coneRadius
DrawSphere position, radius - no rotation
DrawHalfSphere position, radius, rotation
DrawCube start, size, rotation
DrawBounds start, end, rotation - a box given by two opposite corners
DrawCapsule position, height, radius, rotation
DrawCylinder position, height, radius, rotation
DrawCone position, height, radius, rotation
DrawQuad position, size - a Vector2 - and rotation
DrawCircle position, radius, rotation
Note

DrawCapsule, DrawCylinder and DrawCone take height before radius, which is the opposite way round from how most people write it. DrawHalfSphere takes color before rotation, unlike every other rotatable shape. Use named arguments.

Where to see it working

Debug Shapes draws every shape at once, and Debug Shapes Usage is the smaller version showing just the setup.