I’m trying to workout clickable area’s in a transform(Panel)
What I would like is 8 boxes contained within the Panel, but I’m having problems with the coordinates system.
the panel is 292 pixels in width/height and anchored at the bottom left, with a pivot to the bottom left also see screenshot
I’ve workout that the value should be around 41.1625F for a third of 292 pixels in screen system, but when I place the Right line, it’s way to large.
public class TestComponent : MonoBehaviour
{
RectTransform mTransform;
Rect mArea;
void Awake()
{
mTransform = (RectTransform)this.transform;
}
// Use this for initialization
void Start()
{
Single mTop = mTransform.rect.max.y;
Single mRight = mTransform.rect.max.x;
Single mBottom = mTransform.rect.min.y;
Single mLeft = mTransform.rect.min.x;
Single mWidth = mTransform.rect.width;
Single mHeight = mTransform.rect.height;
Vector2 mSize = new Vector2((mWidth / 3) * mTransform.localScale.x , mHeight / 3);
mArea = new Rect(mLeft, mBottom, 41.1625F, mHeight / 3);
Debug.Log("Original: " + mTransform.rect.ToString());
Debug.Log("Area: " + mArea.ToString());
Debug.Log("mSize: " + mSize.ToString());
}
// Update is called once per frame
void Update()
{
// Top
Debug.DrawLine(new Vector3(mArea.min.x, mArea.max.y, 0), new Vector3(mArea.max.x, mArea.max.y, 0), Color.red, 5F);
// Right
Debug.DrawLine(new Vector3(mArea.max.x, mArea.max.y, 0), new Vector3(mArea.max.x, mArea.min.y, 0), Color.cyan, 5F);
// Bottom
Debug.DrawLine(new Vector3(mArea.min.x, mArea.min.y, 0), new Vector3(mArea.max.x, mArea.min.y, 0), Color.blue, 5F);
// Left
Debug.DrawLine(new Vector3(mArea.min.x, mArea.max.y, 0), new Vector3(mArea.min.x, mArea.min.y, 0), Color.green, 5F);
}
}
can anybody help with this, I’m assuming it’s a conversion issue.

