How to generally calculate Rect's position/size/rotation/scale with RectTransform

The need is to calculate a child’s Rect relative to an ascendant RectTransform.
Be concrete, we want to calculate a child item’s Rect in coordinates of ScrollRect’s content. So that we can make the item visible in the ScrollRect’s viewport.

Please know that the items don’t assume having same size, scale, rotation. And even they may not be in same hierarchy level.

So that we ask a generic function that could use as Matrix Multiply.

Do you have the world coordinates of the items you want in the ScrollRect? If so, perhaps you can use InverseTransformPoint? I've never used that function a RectTransorm before (just regular Transforms), but I suspect it will work. positionInScrollRectModelSpace=scrollrectobject.transform.InverseTransformPoint(worldposition);

1 Answer

1

Use this