public override void DrawGizmos() { bool selected = GizmoContext.InActiveSelection(this); Color color = selected ? GizmosColorSelected : GizmosColor; if (StartTransform != null) { Draw.CircleXZ(StartTransform.position, 0.4f, color); } if (EndTransform != null) { Draw.CircleXZ(EndTransform.position, 0.4f, color); } if (StartTransform != null && EndTransform != null) { NodeLink.DrawArch(StartTransform.position, EndTransform.position, color); if (selected) { Vector3 cross = Vector3.Cross(Vector3.up, (EndTransform.position - StartTransform.position)).normalized; NodeLink.DrawArch(StartTransform.position + cross * 0.1f, EndTransform.position + cross * 0.1f, color); NodeLink.DrawArch(StartTransform.position - cross * 0.1f, EndTransform.position - cross * 0.1f, color); } } }
public override void DrawGizmos() { if (tr == null) { tr = transform; } bool selected = GizmoContext.InActiveSelection(tr); var buffer = ListPool <List <Vector3> > .Claim(); GetContour(buffer); var graph = AstarPath.active != null ? (AstarPath.active.data.recastGraph as NavmeshBase ?? AstarPath.active.data.navmesh) : null; var matrix = graph != null ? graph.transform : GraphTransform.identityTransform; float ymid = GetY(matrix); float ymin = ymid - height * 0.5f; float ymax = ymid + height * 0.5f; var col = Color.Lerp(GizmoColor, Color.white, 0.5f); col.a *= 0.5f; using (Draw.WithColor(col)) { // Draw all contours for (int i = 0; i < buffer.Count; i++) { var cont = buffer[i]; for (int j = 0; j < cont.Count; j++) { var p1world = cont[j]; var p2world = cont[(j + 1) % cont.Count]; // Note: Drawn with a stronger color Draw.Line(p1world, p2world, GizmoColor); if (selected) { Vector3 p1 = matrix.InverseTransform(p1world); Vector3 p2 = matrix.InverseTransform(p2world); Vector3 p1low = p1, p2low = p2, p1high = p1, p2high = p2; p1low.y = p2low.y = ymin; p1high.y = p2high.y = ymax; Draw.Line(matrix.Transform(p1low), matrix.Transform(p2low)); Draw.Line(matrix.Transform(p1high), matrix.Transform(p2high)); Draw.Line(matrix.Transform(p1low), matrix.Transform(p1high)); } } } } for (int i = 0; i < buffer.Count; i++) { ListPool <Vector3> .Release(buffer[i]); } ListPool <List <Vector3> > .Release(ref buffer); }
public override void DrawGizmos() { var color = new Color(57 / 255f, 211 / 255f, 46 / 255f); if (!GizmoContext.InActiveSelection(this)) { color.a *= 0.4f; } Draw.Line(transform.position - Vector3.up * maxRange, transform.position + Vector3.up * maxRange, color); }
public GizmosController(GizmoContext context) { _context = context; if (!_context.Gizmos.Any()) { _context.AddRange(GizmosData.Get()); _context.SaveChanges(); } }
public GizmosControllerShould() { var builder = new DbContextOptionsBuilder <GizmoContext>() .UseInMemoryDatabase("Gizmos"); var context = new GizmoContext(builder.Options); if (!context.Gizmos.Any()) { context.AddRange(GizmosData.Get()); context.SaveChanges(); } _ctx = context; }
/// <summary>Draws some gizmos</summary> public override void DrawGizmos() { bool selected = GizmoContext.InActiveSelection(this); Color c = selected ? new Color(227 / 255f, 61 / 255f, 22 / 255f, 1.0f) : new Color(227 / 255f, 61 / 255f, 22 / 255f, 0.9f); if (selected) { var col = Color.Lerp(c, new Color(1, 1, 1, 0.2f), 0.9f); Bounds b = GetBounds(); Draw.SolidBox(b.center, b.size, col); Draw.WireBox(b.center, b.size, col); } if (points == null) { return; } if (convex) { c.a *= 0.5f; } Matrix4x4 matrix = legacyMode && legacyUseWorldSpace ? Matrix4x4.identity : transform.localToWorldMatrix; if (convex) { c.r -= 0.1f; c.g -= 0.2f; c.b -= 0.1f; } using (Draw.WithMatrix(matrix)) { if (selected || !convex) { Draw.Polyline(points, true, c); } if (convex) { if (convexPoints == null) { RecalcConvex(); } Draw.Polyline(convexPoints, true, selected ? new Color(227 / 255f, 61 / 255f, 22 / 255f, 1.0f) : new Color(227 / 255f, 61 / 255f, 22 / 255f, 0.9f)); } // Draw the full 3D shape var pts = convex ? convexPoints : points; if (selected && pts != null && pts.Length > 0) { float miny = pts[0].y, maxy = pts[0].y; for (int i = 0; i < pts.Length; i++) { miny = Mathf.Min(miny, pts[i].y); maxy = Mathf.Max(maxy, pts[i].y); } var extraHeight = Mathf.Max(minBoundsHeight - (maxy - miny), 0) * 0.5f; miny -= extraHeight; maxy += extraHeight; using (Draw.WithColor(new Color(1, 1, 1, 0.2f))) { for (int i = 0; i < pts.Length; i++) { var next = (i + 1) % pts.Length; var p1 = pts[i] + Vector3.up * (miny - pts[i].y); var p2 = pts[i] + Vector3.up * (maxy - pts[i].y); var p1n = pts[next] + Vector3.up * (miny - pts[next].y); var p2n = pts[next] + Vector3.up * (maxy - pts[next].y); Draw.Line(p1, p2); Draw.Line(p1, p1n); Draw.Line(p2, p2n); } } } } }
/// <summary>Draws Gizmos</summary> public override void DrawGizmos() { gizmoDrawing = true; bool selected = GizmoContext.InActiveSelection(this); var movementPlane = RVOSimulator.active != null ? RVOSimulator.active.movementPlane : MovementPlane.XZ; var up = movementPlane == MovementPlane.XZ ? Vector3.up : -Vector3.forward; if (gizmoVerts == null || AreGizmosDirty() || _obstacleMode != obstacleMode) { _obstacleMode = obstacleMode; if (gizmoVerts == null) { gizmoVerts = new List <Vector3[]>(); } else { gizmoVerts.Clear(); } CreateObstacles(); } Matrix4x4 m = GetMatrix(); using (Draw.WithColor(new Color(0.615f, 1, 0.06f, selected ? 1.0f : 0.7f))) { for (int i = 0; i < gizmoVerts.Count; i++) { Vector3[] verts = gizmoVerts[i]; for (int j = 0, q = verts.Length - 1; j < verts.Length; q = j++) { Draw.Line(m.MultiplyPoint3x4(verts[j]), m.MultiplyPoint3x4(verts[q])); } if (selected) { for (int j = 0, q = verts.Length - 1; j < verts.Length; q = j++) { Vector3 a = m.MultiplyPoint3x4(verts[q]); Vector3 b = m.MultiplyPoint3x4(verts[j]); if (movementPlane != MovementPlane.XY) { Draw.Line(a + up * Height, b + up * Height); Draw.Line(a, a + up * Height); } Vector3 avg = (a + b) * 0.5f; Vector3 tang = (b - a).normalized; if (tang == Vector3.zero) { continue; } Vector3 normal = Vector3.Cross(up, tang); Draw.Line(avg, avg + normal); Draw.Line(avg + normal, avg + normal * 0.5f + tang * 0.5f); Draw.Line(avg + normal, avg + normal * 0.5f - tang * 0.5f); } } } } gizmoDrawing = false; }