Change the location of a gameobject in the hierarchy at runtime by scripting

Hi,

Is it possible to change the location of a gameobject in the hierarchy at runtime by scripting?

What I would like to do is the following.

In the hierarchy I have a gameobject at this location:
Parent1 > Child1 > gameobject

I would like to move this gameobject to:
Parent2 > Child2

Parent1 and Parent2 are at the same level.
I think SetSiblingIndex is not working in this case.

Use transform.SetParent:

gameobject.transform.SetParent (Child2.transform);

Thanks.

Yes, that’s working.
Thanks!!