/// <summary> /// Renders the separator line /// </summary> /// <param name="drawRect">The rect to draw the separator within</param> /// <param name="isHovered">True if hovered, false if not</param> /// <param name="context">The object the menu was opened for</param> public override void Draw(Rect drawRect, bool isHovered, System.Object context) { GLExtensions.BeginGUIDrawLinesZDepthOff(separatorColor); GLExtensions.AddLineVertex(new Vector3(drawRect.xMin + NodePadding.left, drawRect.center.y)); GLExtensions.AddLineVertex(new Vector3(drawRect.xMax, drawRect.center.y)); GLExtensions.EndDraw(); }
/// <summary> /// Draws a grid in the specified area /// </summary> /// <param name="gridArea">The area to make the grid in</param> /// <param name="cellSize">The size of the cells</param> /// <param name="lineColor">The colour of the grid lines</param> /// <param name="lineAlpha">The alpha of the lines</param> public static void DrawGrid(Rect gridArea, Vector2 cellSize, Color lineColor, float lineAlpha) { int widthDivs = Mathf.CeilToInt(gridArea.width / cellSize.x); int heightDivs = Mathf.CeilToInt(gridArea.height / cellSize.y); GLExtensions.BeginGUIDrawLinesZDepthOff(new Color(lineColor.r, lineColor.g, lineColor.b, lineAlpha)); Vector3 offset = gridArea.position; Vector3 newOffset = new Vector3(offset.x % cellSize.x, offset.y % cellSize.y, 0f); offset = newOffset; newOffset.y = 0f; for (int i = 0; i < widthDivs; i++) { Vector3 a = new Vector3(cellSize.x * i, 0f, 0f) + newOffset; if (a.x > gridArea.width || a.x < 0f) { continue; } GLExtensions.AddLineVertex(a); GLExtensions.AddLineVertex(new Vector3(cellSize.x * i, gridArea.height, 0f) + newOffset); } newOffset.y = offset.y; newOffset.x = 0f; for (int j = 0; j < heightDivs; j++) { Vector3 a = new Vector3(0f, cellSize.y * j, 0f) + newOffset; if (a.y > gridArea.height || a.y < 0f) { continue; } GLExtensions.AddLineVertex(a); GLExtensions.AddLineVertex(new Vector3(gridArea.width, cellSize.y * j, 0f) + newOffset); } GLExtensions.EndDraw(); }