Positioning RectTransform (centre pivots) Around another RectTransform

Hi there,

Can you please assist in chaning this code for UGUI RectTransforms like a radial layout all the elements equaly forming a circle. Objects will vary from 2 to more (so even if they overlap, no issue) as long as thy are equally distributied.

My ugui rectransforms will be pivot to 0,0 and ill be using AnchoredPosition.
6404265--714669--Capture.PNG

Many Many Thanks in advance

Steps to success:

  • Iterate the N number of times you want
    — clone the object with Instantiate (supply parent as second argument!!!)
    — choose an offset amount (say (1,0,0) for example, or use invisible GameObjects to control it visually)
    — use the iteration number i to generate an evenly-spaced angle (angle = (360 * i) / N)
    — use Quaternion.Euler() with that angle to rotate the offset around Z
    Translate() the cloned object by the rotated offset.
1 Like

Thank you very much for your step by step detailed reply

1 Like