/// <summary>Draw gizmos for the graph</summary> public virtual void OnDrawGizmos(DrawingData gizmos, bool drawNodes, RedrawScope redrawScope) { if (!drawNodes) { return; } // This is a relatively slow default implementation. // subclasses of the base graph class may override // this method to draw gizmos in a more optimized way var hasher = new NodeHasher(active); GetNodes(node => hasher.HashNode(node)); // Update the gizmo mesh if necessary if (!gizmos.Draw(hasher, redrawScope)) { using (var helper = GraphGizmoHelper.GetGizmoHelper(gizmos, active, hasher, redrawScope)) { GetNodes((System.Action <GraphNode>)helper.DrawConnections); } } if (active.showUnwalkableNodes) { DrawUnwalkableNodes(gizmos, active.unwalkableNodeDebugSize, redrawScope); } }
public void OnDrawGizmos(DrawingData gizmos, RedrawScope redrawScope) { var hasher = new NodeHasher(AstarPath.active); hasher.Add(gizmoVersion); if (!gizmos.Draw(hasher, redrawScope)) { using (var builder = gizmos.GetBuilder(hasher, redrawScope)) { var centers = ArrayPool <Vector3> .Claim(areas.Length); for (int i = 0; i < areas.Length; i++) { Int3 center = Int3.zero; var childs = children[i]; if (childs.Count > 0) { for (int j = 0; j < childs.Count; j++) { center += childs[j].position; } center /= childs.Count; centers[i] = (Vector3)center; } } for (int i = 0; i < areas.Length; i++) { if (children[i].Count > 0) { for (int j = 0; j < connections[i].Count; j++) { if (connections[i][j] > i) { builder.Line(centers[i], centers[connections[i][j]], Color.black); } } } } } } }