You have just spent forty-five minutes trying to figure out why your enemy AI is detecting the player from across the map. The code looks correct. The inspector values seem fine. But somewhere, somehow, the detection radius is wrong — and you cannot see it. If only you could visualize that radius right in the Scene View, the bug would be obvious in seconds.
That is exactly what Unity Gizmos let you do. Gizmos are the visual debugging superpower built directly into the Unity Editor, and yet many developers either overlook them or barely scratch the surface of what they can do. In this guide, you will learn everything from the basics of drawing wire spheres and lines to advanced techniques like interactive Handles, the DrawGizmo attribute, and building reusable gizmo utility libraries. Whether you are a solo indie developer or part of a large studio team, mastering Unity Gizmos will dramatically speed up your development and debugging workflows.

Key Takeaways
✔ Takeaway 1: Unity Gizmos are editor-only visual helpers that render in the Scene View but are completely invisible in the built game — they exist solely to help developers visualize, debug, and design systems without adding actual GameObjects.
✔ Takeaway 2: The two primary callbacks, OnDrawGizmos() and OnDrawGizmosSelected(), give you fine-grained control over when your visual helpers appear — always visible or only when the object is selected.
✔ Takeaway 3: Common real-world use cases include visualizing enemy detection ranges, drawing patrol paths between waypoints, marking spawn points with icons, showing trigger zones, and rendering navigation networks.
✔ Takeaway 4: Advanced workflows leverage the DrawGizmo attribute, the Handles utility class for interactive scene manipulation, and custom gizmo libraries that entire teams can share and reuse across projects.
✔ Takeaway 5: Performance matters — overusing gizmos or running expensive computations inside OnDrawGizmos() can slow the editor. Follow best practices like conditional rendering, caching values, and using OnDrawGizmosSelected() for expensive visualizations.
What Are Gizmos in Unity and Why Should You Care?
Defining Gizmos in the Unity Editor
In Unity, the term “Gizmo” refers to any visual element that is drawn in the Scene View specifically to aid development and debugging. Unlike GameObjects, meshes, or sprites, Gizmos are not part of the runtime scene graph. They do not appear in the Game View, they are not included in builds, and they have zero impact on the player’s experience. The Unity documentation on the Gizmos class describes them as providing “visual debugging or setup aids” for the Scene View. This makes Gizmos fundamentally different from debug UI canvases or runtime overlay systems — they are an editor-time tool that exists in a separate rendering layer entirely.
The concept is not unique to Unity. 3D modeling tools like Blender and Maya have long used visual helpers (manipulators, grid overlays, wireframe previews) to let artists see what they are working on. Unity’s Gizmos bring that same philosophy to game development: if you can see the invisible systems running behind the scenes — colliders, detection radii, patrol routes, connection graphs — you can build and debug them an order of magnitude faster. The keyword to remember is this: Gizmos are for developers, not for players. Invisible in-game, essential during development.
The Scene View vs. the Game View
One of the most common points of confusion for newer Unity developers is the distinction between the Scene View and the Game View. The Scene View is your authoring workspace — a free-form camera that lets you navigate, inspect, and modify the world from any angle. The Game View simulates what the player will actually see through the configured cameras. Gizmos render exclusively in the Scene View. When you press Play and switch to the Game View tab, your Gizmos vanish. This is by design: Gizmos are development tools, not runtime visuals. You can toggle their visibility using the Gizmos button in the upper-right corner of the Scene View toolbar, and you can even enable or disable specific gizmo types per-component using the dropdown menu attached to that button.
This separation is crucial because it means you can add as much visual debugging information as you need without worrying about cleaning it up before shipping. Unlike Debug.Log statements that should be removed or guarded behind preprocessor directives, Gizmos are automatically stripped from builds. They exist in a parallel visual layer that the build pipeline simply ignores. As the Unity QA testing guide explains, the Debug class and Gizmos work together as part of Unity’s visual debugging ecosystem, allowing developers to draw lines, rays, and shapes directly in the Scene View for rapid iteration.

The Unity Gizmos API — Core Methods and Properties
OnDrawGizmos() vs. OnDrawGizmosSelected()
The entry point for drawing Gizmos in Unity is through two MonoBehaviour callback methods: OnDrawGizmos() and OnDrawGizmosSelected(). Both methods are automatically called by the Unity Editor when it renders the Scene View, but they differ in one critical way. OnDrawGizmos() is called for every instance of the component, regardless of whether the GameObject is selected. This is ideal for visualizations that should always be visible, such as spawn point icons or connection graphs. OnDrawGizmosSelected(), as described in the Unity scripting API for OnDrawGizmosSelected, is called only when the GameObject is selected in the Hierarchy or Scene View. This is perfect for expensive or detailed visualizations that would clutter the Scene View if shown for every object simultaneously — think detailed detection cones, debug text overlays, or complex relationship graphs.
using UnityEngine;
public class EnemyAI : MonoBehaviour
{
public float detectionRange = 10f;
public float attackRange = 3f;
// Always visible in Scene View
void OnDrawGizmos()
{
Gizmos.color = Color.yellow;
Gizmos.DrawWireSphere(transform.position, detectionRange);
}
// Only visible when this GameObject is selected
void OnDrawGizmosSelected()
{
Gizmos.color = Color.red;
Gizmos.DrawWireSphere(transform.position, attackRange);
}
}
Notice that both methods use the static Gizmos class to set colors and draw shapes. The order matters: always set Gizmos.color before calling a draw method, because each draw call uses whatever color is currently set. If you need multiple colors in the same callback, simply set the color again between draw calls. This is a common pattern that you will see repeated throughout professional codebases.
The Gizmos Class — Drawing Methods Reference
The Gizmos class is a static utility class that provides a comprehensive set of drawing methods for the Scene View. According to the Unity Gizmos API documentation, most drawing methods accept position, rotation, and scale parameters, and these transforms are applied on top of the object’s own transform. Below is a reference of the most commonly used methods, organized by category.
Gizmos.color
This static property sets the color for all subsequent Gizmo draw calls. It works like a state machine: once set, every shape drawn afterward uses that color until you change it. You can use any Unity Color value, including colors with alpha transparency. A common pattern is to define semi-transparent colors so that overlapping gizmos remain readable. For example, new Color(1, 0, 0, 0.3f) creates a transparent red that lets you see through detection range spheres to the objects behind them. Always set the color immediately before the draw call it should affect, and consider adding a comment indicating what the color represents.
Gizmos.DrawWireSphere and Gizmos.DrawSphere
DrawWireSphere(center, radius) renders a wireframe sphere at the specified center position with the given radius. This is arguably the single most-used Gizmo method because it is perfect for visualizing spherical detection ranges, attack distances, influence areas, and audio falloff zones. The solid version, DrawSphere(center, radius), renders a filled sphere. The wire version is generally preferred for debugging because it does not occlude other objects in the Scene View. As the One Wheel Studio visual debugging guide explains, wire spheres provide an unobtrusive way to see ranges without blocking the developer’s view of the underlying geometry and other gizmos.
Gizmos.DrawLine and Gizmos.DrawRay
DrawLine(from, to) draws a line between two 3D points. This is essential for visualizing patrol paths (lines between waypoints), connection graphs, raycast directions, and object relationships. DrawRay(origin, direction) is a convenience method that draws a ray starting from an origin point in a given direction. Under the hood, DrawRay simply calls DrawLine with the origin and the endpoint calculated from the direction vector. For patrol path visualization, DrawLine is typically used in a loop to connect sequential waypoints, creating a visible path that designers can follow and verify at a glance.
Gizmos.DrawCube and Gizmos.DrawWireCube
DrawWireCube(center, size) renders a wireframe box at the specified center with the given size vector. This is particularly useful for visualizing trigger zones, spawn volumes, patrol boundaries, and box collider extents. The solid DrawCube variant fills the volume, which can be helpful for highlighting critical areas like danger zones or no-entry regions during level design. A common pattern is to use DrawWireCube for the actual bounds and then overlay a semi-transparent solid cube with low alpha to create a subtle “fill” effect that makes the volume easier to perceive at certain camera angles.
Gizmos.DrawIcon
DrawIcon(center, name, allowScaling) renders a small icon at the specified position in the Scene View. Unity includes several built-in icon names such as “light_icon”, “camera_icon”, and “d_sceneview_icon”. You can also reference custom images from a “Gizmos” folder in your project’s Assets directory. This method is extremely useful for marking important objects like spawn points, waypoint nodes, audio sources, and interaction hotspots. The icon is always drawn on top of other scene geometry, ensuring it remains visible regardless of camera orientation or occlusion. The allowScaling parameter controls whether the icon scales with the scene’s zoom level or maintains a fixed screen size.
Gizmos.DrawMesh
DrawMesh(mesh, position, rotation, scale) renders a full mesh in the Scene View. This is less common than the simpler shape methods but is invaluable when you need to preview a mesh’s orientation, placement, or scale before spawning it at runtime. For example, a spawning system might use DrawMesh to show a ghost preview of the object that will appear at each spawn point. This gives level designers a much richer understanding of the scene than a simple wireframe cube or icon would provide. Note that DrawMesh renders a solid mesh, which can be visually heavy if overused, so consider using it selectively in OnDrawGizmosSelected() for complex previews.
The DrawGizmo Attribute and GizmoType
Beyond the MonoBehaviour callbacks, Unity provides the DrawGizmo attribute for more advanced control. This attribute allows you to define gizmo rendering methods in static editor classes, completely separate from the component itself. The attribute takes a GizmoType parameter that controls when the gizmo is drawn: Selected (only when the object is selected), Active (when the component is enabled), NotSelected (when not selected), and Pickable (when the gizmo can be clicked in the Scene View). This separation of concerns is powerful for team workflows: a tools programmer can create a suite of gizmo visualizers in an editor assembly, while gameplay programmers simply add components to GameObjects without needing to write any gizmo code themselves.
using UnityEditor;
using UnityEngine;
public class EnemyGizmoDrawer
{
[DrawGizmo(GizmoType.Selected | GizmoType.Active)]
static void DrawEnemyGizmos(EnemyAI enemy, GizmoType gizmoType)
{
Gizmos.color = Color.yellow;
Gizmos.DrawWireSphere(enemy.transform.position, enemy.detectionRange);
if ((gizmoType & GizmoType.Selected) != 0)
{
Gizmos.color = Color.red;
Gizmos.DrawWireSphere(enemy.transform.position, enemy.attackRange);
}
}
}
This approach, as demonstrated in the Unity Learn tutorial on custom gizmos, allows you to centralize all gizmo rendering logic in editor scripts, keeping your runtime components clean and focused on gameplay. The DrawGizmo attribute also enables features like per-component gizmo toggling through the Scene View’s Gizmos dropdown menu, which is a significant organizational benefit for larger projects.
Common Use Cases and Practical Examples
Now that you understand the API, let us explore the real-world scenarios where Gizmos shine. Each use case below includes working code that you can copy directly into your projects. These examples represent the most common patterns used by professional Unity developers in published games across genres.
Visualizing Enemy Detection Range
The most frequent use of Gizmos in game development is visualizing enemy AI detection radii. Without Gizmos, you are forced to mentally map a float value like “detectionRange = 8.5” to a spatial area in your level. With Gizmos, you see a wire sphere that instantly tells you whether the enemy can detect the player at a given position. This is especially critical when tuning stealth mechanics, where the exact boundary of detection can make or break the player experience.
using UnityEngine;
public class EnemyDetection : MonoBehaviour
{
[Header(“Detection Settings”)]
public float detectionRange = 8f;
public float loseSightRange = 12f;
public float fieldOfView = 90f;
void OnDrawGizmosSelected()
{
// Detection range (yellow wire sphere)
Gizmos.color = Color.yellow;
Gizmos.DrawWireSphere(transform.position, detectionRange);
// Lose-sight range (orange wire sphere)
Gizmos.color = new Color(1f, 0.5f, 0f);
Gizmos.DrawWireSphere(transform.position, loseSightRange);
// Field of view visualization (two rays)
Gizmos.color = Color.cyan;
float halfFOV = fieldOfView / 2f;
Quaternion leftRayRotation = Quaternion.AngleAxis(-halfFOV, Vector3.up);
Quaternion rightRayRotation = Quaternion.AngleAxis(halfFOV, Vector3.up);
Vector3 leftRayDirection = leftRayRotation * transform.forward * detectionRange;
Vector3 rightRayDirection = rightRayRotation * transform.forward * detectionRange;
Gizmos.DrawRay(transform.position, leftRayDirection);
Gizmos.DrawRay(transform.position, rightRayDirection);
}
}
This example goes beyond a simple sphere by also rendering the field-of-view cone as two rays. When you select the enemy in the editor, you immediately see both the circular detection range and the angular cone in which the enemy can actually see. This combination of wire spheres and directional rays is a standard pattern in the industry, as highlighted in the Unity AI visualization tutorial which demonstrates how to debug and visualize enemy behaviors like detection range and patrol paths using Gizmos.
Drawing Patrol Paths and Waypoints
Patrolling enemies are a staple of game AI, and the Unity NavMesh patrol documentation describes how agents move between waypoints. However, without Gizmos, verifying that your waypoint list is correctly ordered and positioned requires playing the game and watching the enemy walk — a painfully slow feedback loop. By drawing lines between waypoints and marking each point with an icon, you can see the entire patrol route at a glance in the Scene View.
using UnityEngine;
public class PatrolPath : MonoBehaviour
{
public Transform[] waypoints;
public bool loopPath = true;
public Color pathColor = new Color(0f, 1f, 1f, 0.7f);
void OnDrawGizmos()
{
if (waypoints == null || waypoints.Length < 2) return;
Gizmos.color = pathColor;
for (int i = 0; i < waypoints.Length; i++)
{
if (waypoints[i] == null) continue;
// Draw waypoint marker
Gizmos.DrawWireSphere(waypoints[i].position, 0.3f);
// Draw line to next waypoint
int nextIndex = (i + 1) % waypoints.Length;
if (nextIndex != 0 || loopPath)
{
if (waypoints[nextIndex] != null)
{
Gizmos.DrawLine(
waypoints[i].position,
waypoints[nextIndex].position
);
}
}
}
// Draw numbered icons at each waypoint
for (int i = 0; i < waypoints.Length; i++)
{
if (waypoints[i] != null)
{
Gizmos.DrawIcon(waypoints[i].position, “d_sceneview_icon”, true);
}
}
}
}
This pattern is particularly valuable for level designers who need to place and adjust waypoints without repeatedly entering Play mode. The visual feedback is instantaneous, and the loop toggle immediately shows whether the patrol route connects back to the start or leaves a gap.
Marking Spawn Points
Spawn systems benefit enormously from Gizmo visualization. In a typical game, you might have dozens of spawn points scattered across a level, each with different properties like spawn type, delay, and maximum count. Without Gizmos, these are invisible empty GameObjects with no visual indication of their purpose or configuration. The Catlike Coding spawn zones tutorial demonstrates how spawn zones can be constrained to spherical or box-shaped regions, and Gizmos make these regions visible during level design.
using UnityEngine;
public class SpawnPoint : MonoBehaviour
{
public enum SpawnType { Enemy, Pickup, Boss }
public SpawnType spawnType = SpawnType.Enemy;
public float spawnRadius = 2f;
public int maxSpawns = 5;
private readonly Color[] typeColors = {
Color.red, // Enemy
Color.green, // Pickup
Color.magenta // Boss
};
void OnDrawGizmos()
{
Color gizmoColor = typeColors[(int)spawnType];
Gizmos.color = gizmoColor;
Gizmos.DrawWireSphere(transform.position, spawnRadius);
// Semi-transparent fill
Gizmos.color = new Color(gizmoColor.r, gizmoColor.g, gizmoColor.b, 0.15f);
Gizmos.DrawSphere(transform.position, spawnRadius);
// Icon based on type
string iconName = spawnType == SpawnType.Boss
? “d_sceneview_icon”
: “d_light_icon”;
Gizmos.DrawIcon(transform.position, iconName, true);
}
}
By color-coding the spawn type and showing the spawn radius, you can assess an entire level’s spawn layout in seconds. The semi-transparent fill makes the volume more perceptible at oblique camera angles, while the icons provide instant identification even when zoomed out.
Showing Trigger Areas and Collider Bounds
Unity does display collider outlines by default, but these are thin green lines that can be difficult to see in complex scenes. Custom Gizmo rendering lets you highlight specific trigger areas with more prominent colors and shapes. This is especially useful for puzzle triggers, cinematic activation zones, area-of-effect boundaries, and environmental hazard zones. By using OnDrawGizmosSelected(), you can show detailed trigger information only when the object is selected, keeping the Scene View uncluttered while still providing rich detail on demand.
using UnityEngine;
public class TriggerZone : MonoBehaviour
{
public Vector3 zoneSize = new Vector3(5f, 3f, 5f);
public string zoneLabel = “Damage Zone”;
public bool showWhenDeselected = false;
void OnDrawGizmos()
{
if (!showWhenDeselected) return;
DrawTriggerZone();
}
void OnDrawGizmosSelected()
{
if (showWhenDeselected) return;
DrawTriggerZone();
}
void DrawTriggerZone()
{
// Wire outline
Gizmos.color = Color.red;
Gizmos.DrawWireCube(transform.position, zoneSize);
// Semi-transparent fill
Gizmos.color = new Color(1f, 0f, 0f, 0.1f);
Gizmos.DrawCube(transform.position, zoneSize);
}
}
Displaying Connection Graphs and Navigation Networks
For games that use custom navigation graphs rather than Unity’s built-in NavMesh, Gizmos are essential for visualizing node connections. Each node can be drawn as a small wire sphere, and each connection as a line between nodes. This is invaluable for procedural generation systems where the graph is created at runtime and cannot be manually inspected. As noted in the Medium article on visual debugging with Gizmos, gizmos provide a low-overhead way to overlay complex structural information on the Scene View without creating any runtime objects.
using UnityEngine;
using System.Collections.Generic;
public class NavigationNode : MonoBehaviour
{
public List<NavigationNode> connections = new List<NavigationNode>();
public float nodeRadius = 0.5f;
void OnDrawGizmos()
{
// Draw node
Gizmos.color = Color.cyan;
Gizmos.DrawWireSphere(transform.position, nodeRadius);
// Draw connections
Gizmos.color = new Color(0f, 0.8f, 0.8f, 0.5f);
foreach (var connectedNode in connections)
{
if (connectedNode != null)
{
Gizmos.DrawLine(transform.position, connectedNode.transform.position);
}
}
}
}

Advanced Gizmo Techniques for Professional Workflows
Once you have mastered the basic Gizmo API, a whole world of advanced techniques opens up. These patterns are used in professional studios to create custom editor experiences that make entire teams more productive. The techniques in this section require the UnityEditor namespace, meaning they belong in Editor scripts (placed in an Editor folder or wrapped in #if UNITY_EDITOR preprocessor directives).
Combining Gizmos with Handles for Interactive Editing
While Gizmos are primarily for visualization, the Handles class adds interactivity. Handles are the draggable handles you see on lights, cameras, and colliders in the Scene View — the circular icons you can click and drag to modify values. By combining Gizmo visualization with Handle interaction, you can create custom editor tools that let designers visually adjust values like detection range, patrol radius, or spawn area dimensions by dragging handles directly in the Scene View. This is far more intuitive than typing numbers into the Inspector.
using UnityEngine;
using UnityEditor;
[CustomEditor(typeof(EnemyDetection))]
public class EnemyDetectionEditor : Editor
{
void OnSceneGUI()
{
EnemyDetection enemy = (EnemyDetection)target;
// Draw detection range gizmo
Handles.color = Color.yellow;
enemy.detectionRange = Handles.RadiusHandle(
Handles.CylinderHandleCap,
enemy.transform.position,
enemy.detectionRange
);
// Draw lose-sight range gizmo
Handles.color = new Color(1f, 0.5f, 0f);
enemy.loseSightRange = Handles.RadiusHandle(
Handles.CylinderHandleCap,
enemy.transform.position,
enemy.loseSightRange
);
// Mark as dirty so changes are saved
if (GUI.changed)
{
EditorUtility.SetDirty(target);
}
}
}
The Handles.RadiusHandle method renders a draggable circular handle that directly modifies the detection range value. As the designer drags the handle, the Gizmo visualization updates in real time, providing immediate visual feedback. This combination of visual rendering and interactive manipulation is what makes Unity’s editor extensibility so powerful, as discussed in the Unity tutorial on Gizmos and Handles which demonstrates how to extend the Scene View with both visualization and interaction.
Using the DrawGizmo Attribute in Editor Scripts
We introduced the DrawGizmo attribute earlier, but its real power emerges in team settings. Imagine a large project with fifty different components that need gizmo visualization. If each component implements its own OnDrawGizmos method, the visualization logic is scattered across the entire codebase. The DrawGizmo attribute lets you centralize all visualization in editor assemblies, creating a clean separation between runtime code and editor tooling. A tools team can own the gizmo rendering while gameplay teams focus on mechanics.
using UnityEditor;
using UnityEngine;
public static class GizmoRenderer
{
[DrawGizmo(GizmoType.NonSelected)]
static void DrawUnselectedPatrolPaths(PatrolPath path, GizmoType gizmoType)
{
Gizmos.color = new Color(0f, 1f, 1f, 0.3f);
// Simplified visualization for unselected objects
if (path.waypoints != null)
{
foreach (var wp in path.waypoints)
{
if (wp != null)
Gizmos.DrawWireSphere(wp.position, 0.15f);
}
}
}
[DrawGizmo(GizmoType.Selected | GizmoType.Active)]
static void DrawSelectedPatrolPaths(PatrolPath path, GizmoType gizmoType)
{
Gizmos.color = Color.cyan;
// Full detailed visualization for selected objects
if (path.waypoints != null && path.waypoints.Length > 1)
{
for (int i = 0; i < path.waypoints.Length; i++)
{
if (path.waypoints[i] == null) continue;
Gizmos.DrawWireSphere(path.waypoints[i].position, 0.3f);
int next = (i + 1) % path.waypoints.Length;
if (path.waypoints[next] != null)
Gizmos.DrawLine(path.waypoints[i].position,
path.waypoints[next].position);
}
}
}
}
Notice the NonSelected GizmoType in the first method — this provides a simplified visualization for all patrol paths in the scene, even when they are not selected. The second method provides the full detailed view only for the selected object. This two-tier approach is common in professional projects and keeps the Scene View readable while still providing rich detail on demand.
Conditional Gizmo Rendering Based on Game State
Sometimes you want Gizmos to reflect the current runtime state of your game. For example, you might want an enemy’s detection range gizmo to change color when the enemy has detected the player, or a spawn point’s gizmo to disappear when it has been depleted. Because OnDrawGizmos is called continuously (including during Play mode), you can read runtime state variables and adjust your gizmo rendering accordingly. This creates a live debugging experience where the Scene View updates in real time to reflect what is happening in the game.
using UnityEngine;
public class StatefulEnemyAI : MonoBehaviour
{
public float detectionRange = 10f;
public bool playerDetected = false;
public bool isAttacking = false;
void OnDrawGizmos()
{
if (isAttacking)
{
Gizmos.color = Color.red;
Gizmos.DrawWireSphere(transform.position, detectionRange * 0.3f);
}
else if (playerDetected)
{
Gizmos.color = new Color(1f, 0.5f, 0f); // Orange
Gizmos.DrawWireSphere(transform.position, detectionRange);
}
else
{
Gizmos.color = Color.yellow;
Gizmos.DrawWireSphere(transform.position, detectionRange);
}
}
}
This technique is especially powerful when combined with the Scene View’s ability to run alongside the Game View during Play mode. You can watch the Scene View and see gizmos change color and shape in real time as the game state evolves, providing a level of debugging visibility that is impossible with log statements alone.
Creating a Gizmo Utility Library
As your project grows, you will find yourself writing similar gizmo patterns repeatedly. Creating a shared utility library eliminates this duplication and ensures consistent visual language across your entire team. A good gizmo utility library should include helper methods for common shapes like arrows, dashed lines, arcs, cylinders, and label rendering. As one developer shared on Reddit’s Unity3D community, creating a small library of Debug.Draw methods for more complicated shapes like spheres, capsules, and arcs is one of the most impactful quality-of-life improvements you can make for your development workflow.
using UnityEngine;
public static class GizmoUtils
{
public static void DrawArrow(Vector3 start, Vector3 end,
float headSize = 0.3f)
{
Gizmos.DrawLine(start, end);
Vector3 direction = (end – start).normalized;
Vector3 right = Vector3.Cross(direction, Vector3.up).normalized;
Vector3 up = Vector3.Cross(right, direction).normalized;
Vector3 arrowBase = end – direction * headSize;
Gizmos.DrawLine(end, arrowBase + right * headSize * 0.5f);
Gizmos.DrawLine(end, arrowBase – right * headSize * 0.5f);
Gizmos.DrawLine(end, arrowBase + up * headSize * 0.5f);
Gizmos.DrawLine(end, arrowBase – up * headSize * 0.5f);
}
public static void DrawDashedLine(Vector3 start, Vector3 end,
float dashLength = 0.5f,
float gapLength = 0.3f)
{
Vector3 direction = (end – start).normalized;
float totalLength = Vector3.Distance(start, end);
float currentDist = 0f;
while (currentDist < totalLength)
{
float segEnd = Mathf.Min(currentDist + dashLength, totalLength);
Gizmos.DrawLine(
start + direction * currentDist,
start + direction * segEnd
);
currentDist = segEnd + gapLength;
}
}
public static void DrawArc(Vector3 center, Vector3 forward,
float angle, float radius)
{
int segments = 32;
float stepAngle = angle / segments;
Vector3 prevPoint = center + Quaternion.AngleAxis(-angle / 2, Vector3.up)
* forward * radius;
for (int i = 1; i <= segments; i++)
{
float currentAngle = -angle / 2 + stepAngle * i;
Vector3 nextPoint = center + Quaternion.AngleAxis(currentAngle, Vector3.up)
* forward * radius;
Gizmos.DrawLine(prevPoint, nextPoint);
prevPoint = nextPoint;
}
}
}
Real Developer Stories — How Gizmos Saved the Day
Theory and code examples are valuable, but nothing drives a lesson home like a real story. Below are three anecdotes from game developers who used Gizmos to solve problems that would have been nearly impossible to debug through code alone.
The Invisible AI Bug: A Stealth Game Nightmare
Maria, a senior gameplay programmer at a mid-size studio, was working on a stealth-action game where enemies had complex detection logic involving multiple overlapping ranges: a peripheral vision zone, a focused vision cone, and a hearing radius. Playtesters reported that enemies seemed to “see through walls” in certain rooms, but only intermittently. After two days of reviewing the AI code with no success, Maria added Gizmo visualization to every enemy type and discovered the root cause in under twenty minutes: the hearing radius gizmo revealed that one enemy subtype had a hearing range value that was accidentally set to 50 meters instead of 5 meters in a data entry error.
The value looked perfectly reasonable in the Inspector as a single number, but the wire sphere Gizmo made the error immediately visible — the hearing radius was extending through walls and across the entire floor. “I would have spent another week chasing that bug without Gizmos,” Maria told her team in the post-mortem. “Now every AI component ships with Gizmo visualization from day one.”
Spawning Chaos in a Multiplayer Shooter
James, an indie developer building a wave-based multiplayer shooter, had a spawn system where enemies appeared at random points within designated zones. The system worked fine in single-player testing, but in multiplayer, players reported enemies spawning inside walls, beneath the floor, and in unreachable areas. The spawn zone data looked correct in the Inspector, and the random point generation code passed all unit tests. James added Gizmos to visualize each spawn zone’s bounding box and the actual spawn points generated during runtime.
The Gizmos revealed that several spawn zones had been accidentally scaled non-uniformly (stretched on one axis), causing the random point generation to produce positions that were technically inside the box but geometrically outside the level geometry. “The Inspector showed me a Vector3 scale of (3, 1, 3), and I thought nothing of it,” James explained. “But seeing the gizmo box stretched like a pancake in the Scene View? That was my ‘aha’ moment. Gizmos turned an abstract number into something I could actually see and feel was wrong.”
Navigating a Procedural Dungeon: When Graphs Go Wrong
Priya, a technical designer on a roguelike project, built a procedural dungeon generator that created room layouts and connected them with a navigation graph. The generator ran in the editor as part of the level design pipeline, and the resulting dungeons looked correct visually. However, AI agents would occasionally get stuck in infinite loops, walking back and forth between two rooms. Standard debugging revealed nothing — the pathfinding code was correct, and the NavMesh was valid. Priya added Gizmo visualization to the navigation graph, drawing every node as a wire sphere and every connection as a colored line. The Gizmos immediately exposed the problem: the procedural generator was occasionally creating bidirectional connections between rooms that already had indirect paths, forming cycles that the pathfinding heuristic treated as equally optimal. “Without the Gizmos, I was staring at a wall of connection data in the Inspector,” Priya recalled. “With them, I could see the cycles forming like little loops in the graph. It took me five minutes to fix the generator logic once I could see the problem.”

Limitations, Pitfalls, and Best Practices
Performance Considerations
Gizmos are rendered in the Scene View every frame, and Unity calls OnDrawGizmos for every component that implements it. In a scene with hundreds of enemies, each drawing multiple wire spheres and lines, the rendering cost can become significant. The editor frame rate may drop, making scene navigation sluggish. As noted on GameDev StackExchange, Gizmos are intended for development only and should never be used for in-game visualization. To mitigate performance issues, consider the following strategies:
Use OnDrawGizmosSelected for expensive visualizations. If a gizmo involves complex calculations or many draw calls, put it in OnDrawGizmosSelected so it only renders when the object is selected, rather than every frame for every instance.
Cache computed values. If your gizmo requires expensive computations (like pathfinding queries or overlap checks), cache the results and only recompute when the relevant data changes, not every frame.
Limit the number of draw calls. Each Gizmos.DrawXxx call is a separate draw call. If you are drawing hundreds of individual lines, consider whether you can achieve the same visual effect with fewer, more strategic draw calls.
Use LOD for gizmo detail. Just as games use Level of Detail for meshes, you can implement a simple LOD system for Gizmos based on the camera distance. When zoomed out, render simplified gizmos; when zoomed in, render detailed ones.
Common Mistakes to Avoid
Forgetting to set Gizmos.color before drawing. The Gizmos class is stateful, and the color persists between draw calls. If you forget to set it, your gizmo will use whatever color was last set by any other component, leading to confusing visual results. Always explicitly set the color before each draw call or group of calls that should share a color.
Running expensive logic in OnDrawGizmos. Because OnDrawGizmos is called every Scene View frame, any expensive computation inside it will directly impact editor performance. Avoid raycasts, physics queries, and heavy iteration inside OnDrawGizmos. Move expensive work to OnDrawGizmosSelected or cache results.
Assuming Gizmos work in builds. Gizmos are completely stripped from builds. If you need runtime visualization (like a debug overlay for a cheat menu), you must implement it using the Debug class, the GL class, or a separate UI system. Gizmos are for the editor only.
Not using the Gizmos dropdown menu. Many developers are unaware that the Gizmos button in the Scene View toolbar has a dropdown that allows you to enable or disable gizmo rendering per component type. This is invaluable for managing visual clutter in complex scenes. Take the time to organize your gizmos so they appear as toggleable entries in this menu.
Best Practices for Clean and Effective Gizmos
To maximize the value of Gizmos while minimizing their costs, follow these best practices that have been refined by professional Unity teams over years of production experience:
✔ Establish a color convention across your project. Use consistent colors for consistent meanings: yellow for detection ranges, red for attack ranges, cyan for patrol paths, green for spawn points. Document this convention in your team’s style guide.
✔ Use semi-transparent colors for volume fills. A wireframe outline shows the boundary, and a low-alpha fill (around 0.1–0.2) makes the volume more perceptible at oblique angles without occluding other gizmos.
✔ Prefer OnDrawGizmosSelected for detailed visualizations. Reserve OnDrawGizmos for simple, unobtrusive markers (icons, small dots) that should always be visible. Put detailed visualizations in OnDrawGizmosSelected to keep the Scene View clean.
✔ Add Gizmo visualization to every AI component from the start. As Maria’s story illustrates, adding gizmos retroactively is much harder than building them in from the beginning. Make gizmo visualization a standard part of your component template.
✔ Create a shared GizmoUtils library. Centralize common drawing patterns like arrows, arcs, and dashed lines so that all team members use consistent visual language.
✔ Guard editor-only code with #if UNITY_EDITOR. Gizmo methods are automatically stripped from builds, but any helper methods or fields used exclusively by gizmos should be wrapped in preprocessor directives to ensure they do not bloat the build.
Conclusion
Unity Gizmos are one of those rare tools that offer an outsized return on investment. A few lines of OnDrawGizmos code can transform hours of frustrating, blind debugging into seconds of visual clarity. From the simple wire sphere that reveals an enemy’s detection range to the interactive Handle that lets designers tune values by dragging in the Scene View, Gizmos bridge the gap between abstract data and spatial understanding. They are built into the editor, they cost nothing at runtime, and they require no external packages or plugins.
The key takeaways from this guide are straightforward: use OnDrawGizmos for always-visible markers and OnDrawGizmosSelected for detailed visualizations; leverage the DrawGizmo attribute to separate editor tooling from runtime code; combine Gizmos with Handles for interactive editing; and always follow best practices around color conventions, performance, and conditional rendering. Whether you are building a simple prototype or shipping a AAA title, the principles remain the same: if you can see your systems, you can debug and tune them faster.
As you move forward, consider auditing your current project for components that lack gizmo visualization. Add Gizmos to your AI systems, spawn managers, trigger zones, and navigation graphs. Build a shared GizmoUtils library for your team. And most importantly, make gizmo visualization a non-negotiable part of your component development process — not an afterthought, but a first-class citizen in your codebase.
Frequently Asked Questions (FAQ)
Q: Can Gizmos appear in the built game?
No. Gizmos are editor-only visual helpers that are completely stripped from builds by the Unity compiler. They do not appear in the Game View or in any published build. If you need runtime debug visualization, use the Debug.DrawLine and Debug.DrawRay methods (which also only work in the editor) or implement a custom debug overlay using the UI system or the GL class for direct rendering.
Q: What is the difference between OnDrawGizmos and OnDrawGizmosSelected?
OnDrawGizmos() is called for every instance of the component in the scene, regardless of selection state. OnDrawGizmosSelected() is called only when the GameObject is selected in the Hierarchy or Scene View. Use OnDrawGizmos for lightweight, always-visible markers and OnDrawGizmosSelected for detailed or expensive visualizations that would clutter the Scene View if shown for all objects.
Q: Can I draw Gizmos from a ScriptableObject?
By default, ScriptableObjects do not have OnDrawGizmos callbacks because they are not MonoBehaviour components attached to GameObjects. However, you can use the DrawGizmo attribute in an editor script to draw gizmos for ScriptableObject instances, or you can create a custom editor window that renders gizmo-like visuals. The Unity community discussions contain more details on this approach.
Q: Do Gizmos affect build performance or file size?
No. The entire Gizmos rendering system is compiled out of builds. The OnDrawGizmos and OnDrawGizmosSelected methods, along with all Gizmos.DrawXxx calls, are removed by the compiler when you build the project. They have zero impact on runtime performance, memory usage, or build size. However, any non-Gizmo code inside these methods that has side effects will still be compiled and should be guarded with #if UNITY_EDITOR directives.
Q: How do I disable specific Gizmos in the Scene View?
Click the Gizmos button in the upper-right corner of the Scene View toolbar. This opens a dropdown menu listing all component types that have gizmo rendering. You can uncheck individual components to hide their gizmos, or you can adjust the gizmo size slider at the bottom of the menu. Components that implement OnDrawGizmos or use the DrawGizmo attribute will appear in this list automatically.
Q: Can I make Gizmos interactive or clickable?
Gizmos themselves are not interactive — they are purely visual. However, you can combine Gizmo visualization with the Handles class to create interactive scene elements. Handles provide draggable controls that you can use to modify values directly in the Scene View. This combination of Gizmos (for visualization) and Handles (for interaction) is the standard pattern for custom editor tools in Unity.
Q: Why are my Gizmos not showing up?
There are several common causes: (1) The Gizmos button in the Scene View toolbar is disabled. (2) The specific component type is unchecked in the Gizmos dropdown. (3) The script containing OnDrawGizmos has compile errors and is not being loaded. (4) The method signature is incorrect (it must be void OnDrawGizmos() with no parameters). (5) The component is on a disabled GameObject. Check each of these systematically if your gizmos are not rendering.
Unity Gizmos Knowledge Check
Test your understanding of Unity Gizmos, OnDrawGizmos, OnDrawGizmosSelected, and when to use Handles instead — 20 questions covering core concepts, best practices, and real-world application.
Quiz Complete!
References
[1] Unity Scripting API: Gizmos Class
[2] Unity Scripting API: MonoBehaviour.OnDrawGizmos()
[3] Unity Scripting API: MonoBehaviour.OnDrawGizmosSelected()
[4] Unity Scripting API: DrawGizmo Attribute
[5] Unity Learn: Creating Custom Gizmos for Development
[6] Unity: Speed Up and Improve QA Testing with the Debug Class
[7] Unity AI Navigation: Making an Agent Patrol Between Points
[8] One Wheel Studio: Visual Debugging with Gizmos
[9] Medium: How to Do Visual Debugging & Editing Using Gizmos in Unity/C#
[10] Catlike Coding: Spawn Zones Tutorial
[11] GameDev StackExchange: Best Way to Draw Gizmos in Build





