Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

change parent of gameobject in Unity3d

public GameObject Child;
public Transform NewParent;

// Sets "newParent" as the new parent of the child GameObject.
Child.transform.SetParent(NewParent);

// Removes parent, puts child into a top-level object in the hierarchy
Child.transform.SetParent(null);
 
PREVIOUS NEXT
Tagged: #change #parent #gameobject
ADD COMMENT
Topic
Name
6+9 =