Vertx.Debugging
Vertx.Debugging copied to clipboard
Debugging utilities for Unity
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.
https://user-images.githubusercontent.com/21963717/194199755-a63d8ebc-0cc7-4268-9316-78f7d4fbea1a.mp4
Usage
Shape drawing
Example
You can call these methods from most places, Code strippingCalls to these methods are stripped when building. You do not have to remove code or use defines. |
Drawing Physics and Physics2D operations
ExampleYou can replace calls to
Use Code strippingThe drawing within these methods will be stripped, and the original method is attempted to be inlined, but this is not consistent.
|
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!
Shapes
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
General
| 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. |
3D
Shapes
| Name | Description |
|---|---|
SphereHemisphereBoxCapsuleCylinder |
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. |
ArrowArrowStrip |
An arrow vector, or a collection of points forming an arrow. |
LineLineStrip |
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. |
Plane |
A 3D rect drawn around a point on the plane. |
Cone |
A cone (with adjustable end radius, making a conical frustum). |
Pyramid |
A pyramid. |
Frustum |
A camera frustum. |
FieldOfView |
A 3D field of view, a spherical sector. |
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). |
Casts
| Name | Description |
|---|---|
RaycastLinecastSphereCastBoxCastCapsuleCast |
Using similar parameters asPhysics.RaycastPhysics.LinecastPhysics.SphereCastPhysics.BoxCastPhysics.CapsuleCastwith an optional RaycastHit result. |
RaycastAllSphereCastAllBoxCastAllCapsuleCastAll |
RaycastHit[] results using similar parameters asPhysics.RaycastAllPhysics.SphereCastAllPhysics.BoxCastAllPhysics.CapsuleCastAll |
2D
Shapes
| Name | Description |
|---|---|
Circle2DBox2DArea2DCapsule2DRect |
2D shapes. |
Arc2D |
An arc (using Angle[^1] to define its length). |
Point2D |
A point without a specified direction. |
Axis2D |
An XY direction gizmo. |
Arrow2DArrowStrip2D |
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. |
Casts
| Name | Description |
|---|---|
Raycast2DLinecast2DCircleCast2DBoxCast2DCapsuleCast2D |
Using similar parameters asPhysics2D.RaycastPhysics2D.LinecastPhysics2D.SphereCastPhysics2D.BoxCastPhysics2D.CapsuleCastwith an optional RaycastHit2D result. |
RaycastAll2DCircleCastAll2DBoxCastAll2DCapsuleCastAll2D |
RaycastHit2D[] results using similar parameters asPhysics2D.RaycastAllPhysics2D.SphereCastAllPhysics2D.BoxCastAllPhysics2D.CapsuleCastAll |
[^1]: The helper class Angle is used to define angles, author it with the static methods like Angle.FromDegrees.
Authoring new shapes
ExtensionsThe |
Components
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. |
Installation
Add the OpenUPM registry
Add the package
|