unity setparent method code example
Example 1: unity setparent
public GameObject child;
public GameObject parent;
child.transform.SetParent(parent.transform);
child.transform.SetParent(parent.transform, false);
Example 2: setparent unity
using UnityEngine;public class ExampleClass : MonoBehaviour
{
public GameObject child; public Transform parent;
public void Example(Transform newParent)
{
child.transform.SetParent(newParent);
child.transform.SetParent(newParent, false);
child.transform.SetParent(null);
}
}