Fast editor debugging and gizmo utilities for Unity.
Uses instanced rendering to draw shapes efficiently.
Note
Unity 2019.4+
Should support all render pipelines.
Debugging from jobs and builds is not supported, I recommend Aline if you need that functionality.
vertx_debugging.mp4
Shape drawing
// 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); You can call these methods from most places, Calls to these methods are stripped when building. You do not have to remove code or use defines. |
Drawing Physics
and Physics2D
operations
You can replace calls to int count = DrawPhysics.RaycastNonAlloc(r, results, distance); Use The drawing within these methods will be stripped, and the original method is attempted to be inlined, but this is not consistent. #if UNITY_EDITOR
using Physics = Vertx.Debugging.DrawPhysics;
#endif |
Note
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!
Drawable shapes and casts are contained within the Shape
class. Statically import the class if you use them often:
using static Vertx.Debugging.Shape;
Shape list
Name | Description |
---|---|
Text |
A label in the scene at the provided position. (Text respects 3D gizmo fade distance) |
ScreenText |
A label in the top left of the view. Draws using an Overlay in the Scene view when available. |
Name | Description |
---|---|
Sphere Hemisphere Box Capsule Cylinder |
3D shapes. |
Arc |
An arc (using Angle 1 to define its length). |
Annulus |
An annulus or annulus sector. |
SurfacePoint |
A ray with a circle to indicate the surface. |
Point |
A point without a specified direction. |
Axis |
An 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. |
DashedLine |
A dashed line. |
HalfArrow |
An arrow with only one side of its head. Commonly used to represent the HalfEdge data structure. |
Arrow2DFromNormal |
An 2D arrow aligned in 3D space using a normal vector perpendicular to the direction. |
MeshNormals |
The normals of a mesh. |
Ray |
A 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). |
Name | Description |
---|---|
Raycast Linecast SphereCast BoxCast CapsuleCast |
Using similar parameters asPhysics.Raycast Physics.Linecast Physics.SphereCast Physics.BoxCast Physics.CapsuleCast with an optional RaycastHit result. |
RaycastAll SphereCastAll BoxCastAll CapsuleCastAll |
RaycastHit[] results using similar parameters asPhysics.RaycastAll Physics.SphereCastAll Physics.BoxCastAll Physics.CapsuleCastAll |
Name | Description |
---|---|
Circle2D Box2D Area2D Capsule2D Rect |
2D shapes. |
Arc2D |
An arc (using Angle 1 to define its length). |
Point2D |
A point without a specified direction. |
Axis2D |
An XY direction gizmo. |
Arrow2D ArrowStrip2D |
An arrow vector, or a collection of points forming an arrow. |
Ray2D |
A line from a position and a direction vector. |
Spiral2D |
A 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 . |
Name | Description |
---|---|
Raycast2D Linecast2D CircleCast2D BoxCast2D CapsuleCast2D |
Using similar parameters asPhysics2D.Raycast Physics2D.Linecast Physics2D.SphereCast Physics2D.BoxCast Physics2D.CapsuleCast with an optional RaycastHit2D result. |
RaycastAll2D CircleCastAll2D BoxCastAll2D CapsuleCastAll2D |
RaycastHit2D[] results using similar parameters asPhysics2D.RaycastAll Physics2D.SphereCastAll Physics2D.BoxCastAll Physics2D.CapsuleCastAll |
Authoring new shapes
The |
Components to draw physics events and common object attributes.
Component list
Name | Description |
---|---|
Debug Transform | Draws up, right, forward axes of a Transform. |
Debug Renderer Bounds | Draws the bounds of a Renderer. |
Debug Collider Bounds | Draws the bounds of a Collider or Collider2D. |
Debug Collision Events | Draws OnCollisionEnter , Stay and Exit events. |
Debug Trigger Events | Draws OnTriggerEnter , Stay and Exit events. |
Debug Mesh Normals | Draws normals for a (read/write) Mesh. |
|