Skip to content

VixGizmos Runtime Drawing

Namespace: VixGizmos

Use RuntimeGizmos from gameplay code to draw debug shapes during Play Mode.

Basic Example

using UnityEngine;
using VixGizmos;

public class SensorDebug : MonoBehaviour
{
    private void Update()
    {
        RuntimeGizmos.DrawRay(transform.position, transform.forward * 3f, Color.cyan);
        RuntimeGizmos.DrawWireCube(transform.position, Vector3.one, Color.yellow);
        RuntimeGizmos.DrawWireSphere(transform.position, 1f, Color.green);
        RuntimeGizmos.DrawSolidSphere(transform.position + Vector3.up, 0.25f, new Color(1f, 0f, 0f, 0.35f));
    }
}

Duration

Most draw calls accept a duration parameter.

RuntimeGizmos.DrawLine(start, end, Color.red, duration: 2f);

Use 0 or omit the parameter for one-frame drawing.

3D Helpers

RuntimeGizmos.DrawLine(a, b, Color.white);
RuntimeGizmos.DrawRay(origin, direction, Color.cyan);
RuntimeGizmos.DrawArrow(origin, direction, Color.green);
RuntimeGizmos.DrawWireCube(center, size, Color.yellow);
RuntimeGizmos.DrawWireSphere(center, radius, Color.magenta);
RuntimeGizmos.DrawWireCircle(center, normal, radius, Color.blue);
RuntimeGizmos.DrawSolidCube(center, size, Color.red);
RuntimeGizmos.DrawSolidSphere(center, radius, Color.red);

2D Helpers

2D helpers draw on a configurable plane. The default plane is XY.

RuntimeGizmos.Default2DPlane = RuntimeGizmos.DebugPlane2D.XY;
RuntimeGizmos.Default2DDepth = 0f;

RuntimeGizmos.DrawLine2D(a, b, Color.white);
RuntimeGizmos.DrawRay2D(origin, direction, Color.cyan);
RuntimeGizmos.DrawRect(center, size, Color.yellow);
RuntimeGizmos.DrawCapsule2D(center, size, CapsuleDirection2D.Vertical, Color.green);
RuntimeGizmos.DrawWireCircle(center, radius, Color.magenta);
RuntimeGizmos.DrawCollider2D(collider, Color.red);

Available planes:

  • RuntimeGizmos.DebugPlane2D.XY
  • RuntimeGizmos.DebugPlane2D.XZ
  • RuntimeGizmos.DebugPlane2D.YZ

Enable or Disable Drawing

RuntimeGizmos.enabled = false;
RuntimeGizmos.Clear();