Debug Gizmos
Updated: Oct 27, 2026
In this guide, you will learn how to draw thick debug lines, points, and axes with DebugGizmos in Play mode and at edit time. DebugGizmos is a static drawing API in the Oculus.Interaction namespace for thick debug lines, points, and axes. It belongs to the com.meta.xr.sdk.interaction package and is similar to the Unity Gizmos API.
- A Unity project with the Interaction SDK package installed.
- A
MonoBehaviour in your scene where you add the sample code below. - Code in the
Oculus.Interaction namespace needs no extra using directive, and other namespaces need using Oculus.Interaction;.
DebugGizmos renders in and out of Play mode and on device. In Play mode, DebugGizmos renders segments in its own internal LateUpdate and clears after rendering, so you repeat the calls every frame. At edit time, the class wires OnDrawGizmos internally and hooks Camera.onPreCull, with a SceneView repaint. That edit-time path uses Camera.onPreCull, which only the built-in render pipeline calls. Thick lines use instanced rendering through PolylineRenderer, which draws capsules clipped in the fragment shader.
Draw points, lines, and axes in Play mode
In a MonoBehaviour in your scene, set Color and LineWidth before each Draw call, then repeat those calls every frame to keep the drawing visible. The class stores segments on an internal singleton accessed through static calls and clears them after rendering, so a single call in Start does not persist.
- Set static render state for the next draw.
- Call a
Draw method with world positions. - Repeat the calls every frame to keep the drawing visible.
To visualize a ray, add the following to your behaviour. Replace Origin and End with your own positions:
private void LateUpdate()
{
// Replace with your values.
DebugGizmos.LineWidth = 0.01f;
DebugGizmos.Color = Color.red;
DebugGizmos.DrawLine(Origin, End);
}
To visualize a pointer, add the following to your behaviour. Replace position, rotation, and _radius with your own values:
private void LateUpdate()
{
// Replace with your values.
DebugGizmos.LineWidth = _radius;
DebugGizmos.Color = Color.green;
DebugGizmos.DrawPoint(position);
// Adjust width for axes.
DebugGizmos.LineWidth = _radius * 0.5f;
DebugGizmos.DrawAxis(position, rotation, _radius * 2f);
}
Call a DebugGizmosDraw method from your own OnDrawGizmos method to draw in the Scene view without entering Play mode. Replace center and size with your own values:
private void OnDrawGizmos()
{
// Replace with your values.
DebugGizmos.Color = Color.yellow;
DebugGizmos.LineWidth = 0.01f;
DebugGizmos.DrawWireCube(center, size);
}
LineWidth defaults to 0.1f, so set a smaller width for readable wireframes. For default values, see Configure color, width, and render state.
Note: Edit-time Scene view drawing works only with the built-in render pipeline. If your project uses Universal Render Pipeline (URP), edit-time drawing does not render.
You access DebugGizmos only through static members. You do not create an instance. For namespace setup, see Prerequisites.
Color defaults to Color.black and LineWidth defaults to 0.1f. Width packs into Vector4.w per endpoint. Set both before each draw call because the values apply to the next segment. DrawAxis saves and restores Color after drawing the right axis in red, the up axis in green, and the forward axis in blue.
RenderSinglePass defaults to true, and changing it takes effect on the next Draw call:
DebugGizmos.RenderSinglePass = true;
DebugGizmos.Color = Color.cyan;
DebugGizmos.LineWidth = 0.005f;
DebugGizmos.DrawLine(start, end);
Some Draw methods accept an optional Transform parameter t that transforms points with TransformPoint:
DebugGizmos.DrawLine(p0, p1, t);
DebugGizmos.DrawPoint(p0, t);
Available drawing methods:
public static void DrawPoint(Vector3 p0, Transform t = null)public static void DrawLine(Vector3 p0, Vector3 p1, Transform t = null)public static void DrawQuad(Vector3 center, float width, float height, Transform t = null)public static void DrawCurvedQuad(Vector3 center, float width, float height, float radius, Transform t = null, int divisions = 20)public static void DrawWireCube(Vector3 center, float size, Transform t = null)public static void DrawAxis(Vector3 position, Quaternion rotation, float size = 1.0f)public static void DrawAxis(Pose pose, float size = 1.0f)public static void DrawAxis(Transform t, float size = 1.0f)
Drawing appears for one frame then disappears
Symptom: The drawing renders once and then vanishes.
Solution: Make sure the Draw calls run every frame. Segments clear after rendering, so calling them for only a single frame does not persist.
Nothing renders in the Scene view at edit time
Symptom: No drawing appears in the Scene view without entering Play mode.
Solution: Call a Draw method from your own OnDrawGizmos method and set Color before the call. This fix works only with the built-in render pipeline. If your project uses Universal Render Pipeline (URP), view the drawing in Play mode.