private void DrawIndicatorH(Rect rect, float value, float minV, float maxV) { GUI.BeginGroup(rect); bool clamped = false; if (value < minV) { value = minV; clamped = true; } if (value > maxV) { value = maxV; clamped = true; } float sx = rect.width; float sy = rect.height; GUI.Box(new Rect(0, 0, sx, sy), ""); Color color = XKCDColors.NeonGreen; float spacing = (float)Math.Floor(sx * 0.11f + 0.5f); float middle = (float)Math.Floor(sx * 0.5f + 0.5f); Rect lineRect = new Rect(0, 3, 1, sy - 6); for (float x = middle + spacing; x < sx; x += spacing) { lineRect.x = x; Drawing.DrawRect(lineRect, color); } for (float x = middle - spacing; x > 0; x -= spacing) { lineRect.x = x; Drawing.DrawRect(lineRect, color); } lineRect.x = middle - 1; lineRect.y = 1; lineRect.height = sy - 3; lineRect.width = 3; color = XKCDColors.NeonBlue; Drawing.DrawRect(lineRect, color); // our box runs for 0 to sx-1 // we do not want diamond to get clipped // so lowest y should be 0 and highest should be (sx-1)-9 // center should draw at middle - 4 float frac = -0.5f + (value - minV) / (maxV - minV); // range -0.5 to 0.5 float range = (sx - 1) - 9; float xx = middle + range * frac - 4; Color dcolor = clamped ? XKCDColors.NeonRed : XKCDColors.NeonBlue; Drawing.DrawDiamond(new Rect(xx, 3, 9, 15), dcolor); GUI.EndGroup(); }