unity – Box selection with Physics2D.BoxCastAll is mirrored when selecting in the bottom half of the screen

enter image description here

Using Physics2D.BoxCastAll based on rectangle is working fine when drawing is started on the top part of the screen, but when drawing is started on the bottom you can see this strange mirroring effect.

Code:

    void OnGUI()
{
    // LMB clicked
    if (Input.GetMouseButtonDown(0))
    {
        boxStartPosition = new Vector2(
            Input.mousePosition.x,
            Screen.height - Input.mousePosition.y
          );
    }

    // LMB drag
    if (Input.GetMouseButton(0))
    {
        boxEndPosition = new Vector2(
            Input.mousePosition.x,
            Screen.height - Input.mousePosition.y
        );

        rectangle = new Rect(
            boxStartPosition.x,
            boxStartPosition.y,
            boxEndPosition.x - boxStartPosition.x,
            boxEndPosition.y - boxStartPosition.y
        );

        GUI.DrawTexture(rectangle, RectangleTexture);

        float pixelsToWorld = Camera.main.orthographicSize / (Screen.height / 2f);

        Vector2 boxCenter = Camera.main.ScreenToWorldPoint(rectangle.center);

        boxCenter.y = Mathf.Abs(boxCenter.y);

        float boxWidth = Mathf.Abs(rectangle.size.x) * pixelsToWorld;
        float boxHeight = Mathf.Abs(rectangle.size.y) * pixelsToWorld;
        Vector2 boxSize = new Vector2(boxWidth, boxHeight);

        BoxCastDebug.DrawBoxCast2D(boxCenter, boxSize, 0f, Vector2.zero, 0f, Color.black);
        hits = Physics2D.BoxCastAll(boxCenter, boxSize, 0f, Vector2.zero, 0f);
    }

Can anyone help me to solve these issues? Is it directly connected with setup of my scene, camera or scripts?