Skip to content

Gizmo Extensions

yart edited this page Jul 21, 2025 · 6 revisions

We have some convenient methods for quickly drawing depth-indicating gizmos using any instance of a Component.

Component Extension Methods

  • this.DrawArrow( Vector3 from, Vector3 to, Color c, float? len = null, float? w = null, Transform? tWorld = null )
  • this.DrawSphere( in float radius, in Vector3 center, Color c, Transform? tWorld = null )
  • this.DrawBox( in BBox box, Color c, Transform? tWorld = null )

Depth Indication

Depth is indicated in these methods by rendering a shape with the specified color very transparently without depth testing(through walls), then again with depth testing using the full color.

This simple technique lets you know something's there even through walls and how much of it is stuck through the floor or whatever.

Recommended Usage

From a Component, in OnUpdate or DrawGizmos just type this.DrawBox(..)(for example).

You can specify only the shape's properties and color and it will(by default) render the shape using the position/scale/rotation of the Component you called the method from(the GameObject it's on to be more accurate). You can however override where it's at by typing tWorld: .. as an argument in the method.

If you want your render code to show ingame then call the methods in OnUpdate. If you want the same code to show in the editor then you can have your component inherit Component.ExecuteInEditor, but you likely want have features meant only for play mode prevented in the editor with:

if ( !this.InGame() ) return;

Clone this wiki locally