unity destroy all children

[ad_1]

unity delete all children
 foreach (Transform child in transform) {
     Destroy(child.gameObject);
 }
unity destroy all children
while (transform.childCount > 0) {
    DestroyImmediate(transform.GetChild(0).gameObject);
}
Unity Destroy All Children
void Update()
    {
    //put in any gameobject having children and enter playmode
        foreach (Transform child in transform)
        {
            Destroy(child.gameObject);
        }
    }
Unity Children Destroy
 //put in any gameobject having children and enter playmode
        while (transform.childCount > 0)
        {
            DestroyImmediate(transform.GetChild(0).gameObject);
        }

[ad_2]

Please follow and like us:
Content Protection by DMCA.com