public static void OnDrawGizmos(this NavmeshBase navmeshBase, Pathfinding.Util.RetainedGizmos gizmos, bool drawNodes) { if (!drawNodes) { return; } using (var helper = gizmos.GetSingleFrameGizmoHelper()) { var bounds = new Bounds(); bounds.SetMinMax(Vector3.zero, navmeshBase.forcedBoundsSize); // Draw a write cube using the latest transform // (this makes the bounds update immediately if some field is changed in the editor) helper.builder.DrawWireCube(navmeshBase.CalculateTransform(), bounds, Color.white); } if (navmeshBase.tiles != null) { // Update navmesh vizualizations for // the tiles that have been changed for (int i = 0; i < navmeshBase.tiles.Length; i++) { // This may happen if an exception has been thrown when the graph was scanned. // We don't want the gizmo code to start to throw exceptions as well then as // that would obscure the actual source of the error. if (navmeshBase.tiles[i] == null) { continue; } // Calculate a hash of the tile var hasher = new RetainedGizmos.Hasher(AstarPath.active); hasher.AddHash(navmeshBase.showMeshOutline ? 1 : 0); hasher.AddHash(navmeshBase.showMeshSurface ? 1 : 0); hasher.AddHash(navmeshBase.showNodeConnections ? 1 : 0); var nodes = navmeshBase.tiles[i].nodes; for (int j = 0; j < nodes.Length; j++) { hasher.HashNode(nodes[j]); } if (!gizmos.Draw(hasher)) { using (var helper = gizmos.GetGizmoHelper(hasher)) { if (navmeshBase.showMeshSurface || navmeshBase.showMeshOutline) { navmeshBase.CreateNavmeshSurfaceVisualization(navmeshBase.tiles[i], helper); } if (navmeshBase.showMeshSurface || navmeshBase.showMeshOutline) { CreateNavmeshOutlineVisualization(navmeshBase.tiles[i], helper); } if (navmeshBase.showNodeConnections) { for (int j = 0; j < nodes.Length; j++) { helper.DrawConnections(nodes[j]); } } } } gizmos.Draw(hasher); } } if (AstarPath.active.showUnwalkableNodes) { navmeshBase.DrawUnwalkableNodes(AstarPath.active.unwalkableNodeDebugSize); } }