// Will be called after all regular rendering is done private IEnumerator DrawLoop() { CreateLineMaterial(ref DebugLineMaterial); while (true) { yield return(new WaitForEndOfFrame()); GL.PushMatrix(); // Apply the line material DebugLineMaterial.SetPass(0); //set up an ortho perspective transform GL.LoadPixelMatrix(); // Draw lines GL.Begin(GL.LINES); while (_rectStack.Count > 0) { DrawRectRequest rect = _rectStack[0]; DrawFilledRect(rect); _rectStack.RemoveAt(0); } GL.End(); GL.PopMatrix(); } yield return(null); }
private void DrawFilledRect(DrawRectRequest rect) { DrawSolidRectangle(rect.topLeft + new Vector3(0, -debugHitboxBorderWidth, 0), rect.topRight, rect.color); DrawSolidRectangle(rect.bottomLeft, rect.bottomRight + new Vector3(0, debugHitboxBorderWidth, 0), rect.color); Color innerColor = rect.color; innerColor.a = .6f; for (int y = (int)rect.bottomRight.y + debugHitboxBorderWidth; y < rect.topRight.y - debugHitboxBorderWidth; y++) { DrawLine(new Vector3(rect.topLeft.x + debugHitboxBorderWidth, y, rect.topLeft.z), new Vector3(rect.topRight.x - debugHitboxBorderWidth, y, rect.topRight.z), innerColor); } }
public void AddDebugCollider(FGRectCollider collider) { Rect r = collider.GetRect(); Vector3 topLeft = new Vector2(r.position.x, r.position.y + r.size.y); Vector3 bottomLeft = new Vector2(r.position.x, r.position.y); Vector3 topRight = new Vector2(r.position.x + r.size.x, r.position.y + r.size.y); Vector3 bottomRight = new Vector2(r.position.x + r.size.x, r.position.y); DrawRectRequest rect = new DrawRectRequest(); rect.topLeft = topLeft; rect.topRight = topRight; rect.bottomLeft = bottomLeft; rect.bottomRight = bottomRight; rect.color = _colors[collider.type]; _rectStack.Add(rect); }