Converting between RectTransform coordinates

Hi all,

I have a UI layout that looks like this:

– Panel A
---- GridLayout
------- Elements
– Panel B

Both panels use the anchors to position themselves on the canvas, with offsets of (0, 0, 0, 0). Panel B is a full (0, 0, 1, 1) overlay.

What I want now is to spawn a new UI prefab (again using anchored positions) onto panel B, at the center position of one of the layout-controlled Elements.

However, I can’t seem to figure out how to obtain this calculated position in “Panel B space”. I’m already waiting until the layout is completed with a WaitForEndOfFrame. Any thoughts?

Thanks!

I would have thought the easiest way would be to get the real world coordinates of the Grid Element using “GetWorldCorners”, then use that to calculate the anchor / pivot position for the new element, translate it back to screenspace and then parent it to panel B.

The ReorderableList in the UI Extensions does something very similar I believe.