protected void DrawDataPoint(float xPosition, float verticalScale, ProfilerFrame frame) { // Right-hand x-coord var rx = Mathf.Min(_clipBounds.width / 2f, xPosition + DataPointWidth - DataPointMargin); var currentLineHeight = 0f; for (var j = 0; j < LineCount; j++) { var lineIndex = j; var value = 0f; if (j == 0) { value = (float)frame.UpdateTime; } else if (j == 1) { value = (float)frame.RenderTime; } else if (j == 2) { value = (float)frame.OtherTime; } value *= verticalScale; if (value.ApproxZero() || value - DataPointVerticalMargin * 2f < 0f) { continue; } // Lower y-coord var ly = currentLineHeight + DataPointVerticalMargin - rectTransform.rect.height / 2f; if (VerticalAlignment == VerticalAlignments.Top) { ly = rectTransform.rect.height / 2f - currentLineHeight - DataPointVerticalMargin; } // Upper y-coord var uy = ly + value - DataPointVerticalMargin; if (VerticalAlignment == VerticalAlignments.Top) { uy = ly - value + DataPointVerticalMargin; } var c = LineColours[lineIndex]; AddRect(new Vector3(Mathf.Max(-_clipBounds.width / 2f, xPosition), ly), new Vector3(Mathf.Max(-_clipBounds.width / 2f, xPosition), uy), new Vector3(rx, uy), new Vector3(rx, ly), c); currentLineHeight += value; } }
public static bool MinorOrEquals(this float a, float b) { float result = a - b; return(result < 0 || result.ApproxZero()); }