public Vector2 GetRectSize(RectTransform rect)
        {
            Vector3[] corners = new Vector3[4];
            rect.GetWorldCorners(corners);


            for (int i = 0; i < corners.Length; i++)
            {
                corners[i] = ScreenRect.InverseTransformPoint(corners[i]);
            }

            return(new Vector2(
                       Math.Abs(corners[0].x - corners[2].x),
                       Math.Abs(corners[0].y - corners[2].y)));
        }
        public Vector2 GetRectCenter(RectTransform rect)
        {
            Vector3[] corners = new Vector3[4];
            rect.GetWorldCorners(corners);


            for (int i = 0; i < corners.Length; i++)
            {
                corners[i] = ScreenRect.InverseTransformPoint(corners[i]);
            }

            var size = GetRectSize(rect);

            return(new Vector2(
                       corners[0].x + size.x / 2,
                       corners[0].y + size.y / 2));
        }