-
Notifications
You must be signed in to change notification settings - Fork 0
Gizmo Extensions
We have some convenient methods for quickly drawing depth-indicating gizmos using any instance of a Component
.
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 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.
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;