README.md

November 24, 2025 · View on GitHub

Fast editor debugging and gizmo utilities for Unity.
Uses instanced rendering to draw shapes efficiently.

Note


Unity 2022.2+ (all features) - Version 3.0.0 and above.
2019.4+ No jobs and burst support, older API.

Should support all render pipelines.
Supports drawing from jobs and burst. This package depends on Burst and Mathematics.
All shapes are wireframe. There is currently no support for solid shapes planned.

https://user-images.githubusercontent.com/21963717/194199755-a63d8ebc-0cc7-4268-9316-78f7d4fbea1a.mp4

Usage

Shape drawing

Example

// Draw a sphere with the specified color.
D.raw(new Shape.Sphere(position, radius), color, duration);

// Draw green sphere if nothing was hit,
// or draw a red sphere if something was.
D.raw(new Shape.Sphere(position, radius), hit, duration);

// Casts draw in green, with red where hits were detected if no color is provided.
// Cast color and hit color can be overrided manually.
D.raw(new Shape.SphereCastAll(position, direction, radius, hits, hitCount, 10), duration);

Available contexts

You can call these methods from most places, Update, LateUpdate, FixedUpdate, OnDrawGizmos, and with ExecuteAlways/ExecuteInEditMode.
If drawn from a gizmo context, duration parameters will be ignored. Gizmos.matrix works, Gizmos.color is unsupported. Gizmos are not pickable.

Code stripping

Calls to these methods are stripped when building. You do not have to remove code or use defines.
If your code spans many statements, only the method call will be stripped.

Drawing Physics and Physics2D operations

Example

You can replace calls to Physics and Physics2D methods with DrawPhysics and DrawPhysics2D to simply draw the results of a physics operation.

int count = DrawPhysics.RaycastNonAlloc(r, results, distance);

Use DrawPhysicsSettings.SetDuration or Duration to override the length of time the casts draw for. You will need to reset this value manually. Calls to Duration cannot be stripped, I would recommend using SetDuration if this is important to you.

Code stripping

The drawing within these methods will be stripped, and the original method is attempted to be inlined, but this is not consistent.
A single method call doesn't matter when compared to a physics operation, but you can completely strip these calls by instead declaring:

#if UNITY_EDITOR
using Physics = Vertx.Debugging.DrawPhysics;
#endif

Note


Gizmos must be enabled in the view.
3D gizmos support fading, but may be inconsistent between Unity versions.

If you find you have rendering issues like upside-down depth testing, or artifacts in the game view: This is a Unity bug.
You can disable Depth Write and Depth Test in the problematic view using the settings in Project Settings > Vertx > Debugging.
If you're on a version of Unity where the settings UI doesn't work, it's another Unity bug, thanks Unity!

Shapes

Drawable shapes and casts are contained within the Shape class. You can statically import the class if you use them often:

using static Vertx.Debugging.Shape;
Shape list

General

NameDescription
TextA label in the scene at the provided position. (Text respects 3D gizmo fade distance)
Not currently supported in jobs.
ScreenTextA label in the top left of the view.
Draws using an Overlay in the Scene view when available.
Not currently supported in jobs.

3D

Shapes

NameDescription
Sphere
Hemisphere
Box
Capsule
Cylinder
3D shapes.
ArcAn arc (using Angle1 to define its length).
AnnulusAn annulus or annulus sector.
SurfacePointA ray with a circle to indicate the surface.
PointA point without a specified direction.
AxisAn XYZ direction gizmo.
Arrow
ArrowStrip
An arrow vector, or a collection of points forming an arrow.
Line
LineStrip
A line, or a collection of points that make up a line.
DashedLineA dashed line.
HalfArrowAn arrow with only one side of its head. Commonly used to represent the HalfEdge data structure.
Arrow2DFromNormalAn 2D arrow aligned in 3D space using a normal vector perpendicular to the direction.
PlaneA 3D rect drawn around a point on the plane.
ConeA cone (with adjustable end radius, making a conical frustum).
PyramidA pyramid.
FrustumA camera frustum.
FieldOfViewA 3D field of view, a spherical sector.
MeshNormalsThe normals of a mesh.
CatenarySimilar to cable hanging between two points.
RayA line from a position and a direction vector.
Ray (Built-in)Fallback to Ray.
Vector3 (Built-in)Fallback to Point.
RaycastHit (Built-in)Fallback to SurfacePoint.
Bounds (Built-in)Fallback to Box.
Collider (Built-in)Fallback to the correct shape matching the collider type (primitive colliders only).

Casts

NameDescription
Raycast
Linecast
SphereCast
BoxCast
CapsuleCast
Using similar parameters as
Physics.Raycast
Physics.Linecast
Physics.SphereCast
Physics.BoxCast
Physics.CapsuleCast
with an optional RaycastHit result.

RaycastAll
SphereCastAll
BoxCastAll
CapsuleCastAll
RaycastHit[] results using similar parameters as
Physics.RaycastAll
Physics.SphereCastAll
Physics.BoxCastAll
Physics.CapsuleCastAll

2D

Shapes

NameDescription
Circle2D
Box2D
Area2D
Capsule2D
Rect
2D shapes.
Arc2DAn arc (using Angle1 to define its length).
Point2DA point without a specified direction.
Axis2DAn XY direction gizmo.
Arrow2D
ArrowStrip2D
An arrow vector, or a collection of points forming an arrow.
Ray2DA line from a position and a direction vector.
Spiral2DA spiral, useful for visualising rotation on wheels.
Vector2 (Built-in)Fallback to Point2D.
RaycastHit2D (Built-in)Fallback to Ray.
Rect (Built-in)Fallback to Box2D.

Casts

NameDescription
Raycast2D
Linecast2D
CircleCast2D
BoxCast2D
CapsuleCast2D
Using similar parameters as
Physics2D.Raycast
Physics2D.Linecast
Physics2D.SphereCast
Physics2D.BoxCast
Physics2D.CapsuleCast
with an optional RaycastHit2D result.

RaycastAll2D
CircleCastAll2D
BoxCastAll2D
CapsuleCastAll2D
RaycastHit2D[] results using similar parameters as
Physics2D.RaycastAll
Physics2D.SphereCastAll
Physics2D.BoxCastAll
Physics2D.CapsuleCastAll
Authoring new shapes

Extensions

  1. Reference the runtime assembly by either:
    • Using Assembly Definition References to add a class to the runtime assembly.
    • Creating an Assembly Definition named "Vertx.Debugging.Runtime.Extensions" and referencing Vertx.Debugging.Runtime.
  2. The Shape class is partial. You can add IDrawable or IDrawableCast structs to the class, which will be compatible with D.raw<T>(T shape).
  3. Use the UnmanagedCommandBuilder Append functions to create your own shapes, or combine other shapes by directly calling their Draw functions.

Warning


Don't recursively call D.raw from inside of IDrawable/IDrawableCast.Draw, as it will cause issues with FixedUpdate drawing.

Components

Components to draw physics events and common object attributes.

Component list
NameDescription
Debug TransformDraws up, right, forward axes of a Transform.
Debug Renderer BoundsDraws the bounds of a Renderer.
Debug Collider BoundsDraws the bounds of a Collider or Collider2D.
Debug Collision EventsDraws OnCollisionEnter, Stay and Exit events.
Debug Trigger EventsDraws OnTriggerEnter, Stay and Exit events.
Debug Mesh NormalsDraws normals for a (read/write) Mesh.

Drawing from jobs

Drawing shapes other than text from jobs is supported (parallel, and bursted).

Note that drawing from jobs scheduled from a fixed timestep context like FixedUpdate or FixedStepSimulationSystemGroup is not time-adjusted which may cause flickering based on the framerate, you must manually call DrawPhysicsUtility.GetFixedFrameJobDuration to get a time-adjusted duration, and pass it to D.raw to draw shapes correctly in this context.

Installation

openupm

Add the OpenUPM registry

  1. Open Edit/Project Settings/Package Manager
  2. Add a new Scoped Registry (or edit the existing OpenUPM entry):
    Name: OpenUPM
    URL:  https://package.openupm.com/
    Scope(s): com.vertx
    
  3. Save

Add the package

  1. Open the Package Manager via Window/Package Manager.
  2. Select the + from the top left of the window.
  3. Select Add package by Name or Add package from Git URL.
  4. Enter com.vertx.debugging.
  5. Select Add.
  6. If Burst is added for the first time or its version is changed you will need to restart Unity.

ko-fi

Footnotes

  1. The helper class Angle is used to define angles, author it with the static methods like Angle.FromDegrees. 2