I’ve tried transform.SetParent(canvas.transform, true) but this doesn’t work.
I think your description lacks information. But let me look into my crystal ball: Actually the re-link to another parent works but the positions are screwed up. right?
The reason is that the UI elements (which use RectTransform instead of Transform) have much more complicated positioning calculations than “normal” unity objects. You have to take the anchors into account. The “worldPositionStays” parameter is not for changing UI Parents. It is for keeping the global position / orientation rather than the local one… but it doesn’t care about anchoring.
There are ways to get the transforms right, but it is not that easy. Maybe this thread points you in the right direction: Find anchoredPosition of a RectTransform relative to another RectTransform
Yes, that’s the exact question I was asking in the subject line, so no need for a crystal ball. Thanks for your help, the thread link will certainly be useful.