public static void DrawRoundedCorners(RoundedRect rect, int lines = 8) { lines = Mathf.Clamp(lines, 4, 20); // Let's not go insane on this. Vector3 radiusRight = new Vector3(rect.radius, 0); Vector3 radiusTop = new Vector3(0, rect.radius); Vector3 topRight = new Vector3(rect.squareRight, rect.squareTop); Vector3 topLeft = new Vector3(rect.squareLeft, rect.squareTop); Vector3 bottomLeft = new Vector3(rect.squareLeft, rect.squareBottom); Vector3 bottomRight = new Vector3(rect.squareRight, rect.squareBottom); DrawGizmoSlerp(topRight, radiusRight, radiusTop, lines); DrawGizmoSlerp(topLeft, -radiusRight, radiusTop, lines); DrawGizmoSlerp(bottomLeft, -radiusRight, -radiusTop, lines); DrawGizmoSlerp(bottomRight, radiusRight, -radiusTop, lines); }
public static void Draw(RoundedRect rect) { Color gizmoColor = Gizmos.color; if (rect.isRounded) { DrawRounded(rect); Gizmos.color = gizmoColor * new Color(1, 1, 1, 0.3f); DrawSquare(rect); } else { DrawSquare(rect); } Gizmos.color = gizmoColor; }
public static void DrawSquare(RoundedRect rect) { Vector3 l0s = new Vector3(rect.squareRight, rect.squareBottom); Vector3 l0e = new Vector3(rect.squareRight, rect.squareTop); Gizmos.DrawLine(l0s, l0e); Vector3 l1s = new Vector3(rect.squareRight, rect.squareTop); Vector3 l1e = new Vector3(rect.squareLeft, rect.squareTop); Gizmos.DrawLine(l1s, l1e); Vector3 l2s = new Vector3(rect.squareLeft, rect.squareTop); Vector3 l2e = new Vector3(rect.squareLeft, rect.squareBottom); Gizmos.DrawLine(l2s, l2e); Vector3 l3s = new Vector3(rect.squareLeft, rect.squareBottom); Vector3 l3e = new Vector3(rect.squareRight, rect.squareBottom); Gizmos.DrawLine(l3s, l3e); }
public static void DrawRoundedEdges(RoundedRect rect) { // Draw expanded edges Vector3 l0s = new Vector3(rect.roundedRight, rect.squareBottom); Vector3 l0e = new Vector3(rect.roundedRight, rect.squareTop); Gizmos.DrawLine(l0s, l0e); Vector3 l1s = new Vector3(rect.squareRight, rect.roundedTop); Vector3 l1e = new Vector3(rect.squareLeft, rect.roundedTop); Gizmos.DrawLine(l1s, l1e); Vector3 l2s = new Vector3(rect.roundedLeft, rect.squareTop); Vector3 l2e = new Vector3(rect.roundedLeft, rect.squareBottom); Gizmos.DrawLine(l2s, l2e); Vector3 l3s = new Vector3(rect.squareLeft, rect.roundedBottom); Vector3 l3e = new Vector3(rect.squareRight, rect.roundedBottom); Gizmos.DrawLine(l3s, l3e); }
public static void DrawRounded(RoundedRect rail) { DrawRoundedEdges(rail); DrawRoundedCorners(rail); }