using UnityEngine;

public class PanelPositions : MonoBehaviour {
    public Canvas canvas;
    public RectTransform mapPanelTransform;

    public Rect MapRect {
        get {
            Vector3[] corners = new Vector3[4];
            mapPanelTransform.GetWorldCorners(corners);
            Vector3 topLeft =
                    new Vector3(corners[1].x, canvas.pixelRect.height - corners[1].y, corners[1].z);

            Vector2 scaledSize = new Vector2(
                    canvas.scaleFactor * mapPanelTransform.rect.size.x,
                    canvas.scaleFactor* mapPanelTransform.rect.size.y);
            return new Rect(topLeft, scaledSize);
        }
    }
}
