I have a Panel that's positioned in the center of my scene (horizontal and vertical). I insert Buttons at runtime into the Panel. To resize the Panel depending of its content I added a Vertical Layout Group and a Content Size Fitter onto it.
This works fine, but now I want to add a close Button and try to position it at the top right corner of the panel. Any idea how I can get the position of the top right corner to position my close button accordingly?
You can see the close button (X) at the bottom of the screenshot. I tried to position it like that:
RectTransform menuRect = menu.GetComponent ();
RectTransform closeRect = close.GetComponent ();
closeRect.position = new Vector3 (closeRect.position.x, menuRect.sizeDelta.y, closeRect.position.z);
![alt text][1]
[1]: /storage/temp/112006-panel-rectransform.png
↧