set gameobject as parent unity3d code example
Example 1: unity change parent in script
player.transform.parent = newParent.transform;
Example 2: set parent of gameobject unity
child.transform.SetParent(newParent);
player.transform.parent = newParent.transform;
child.transform.SetParent(newParent);