Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

unity delete all children

 foreach (Transform child in transform) {
     Destroy(child.gameObject);
 }
Comment

c# unity destroy all child gameobject

public GameObject objParent;

// Destory every child game object
for (int i = objParent.transform.childCount - 1; i >= 0; i--)
{
    Object.Destroy(objParent.transform.GetChild(i).gameObject);
}
Comment

deactivate all children unity

foreach (Transform child in transform)
    child.gameObject.SetActive(false);
Comment

unity destroy all children

while (transform.childCount > 0) {
    DestroyImmediate(transform.GetChild(0).gameObject);
}
Comment

Unity Children Destroy

 //put in any gameobject having children and enter playmode
        while (transform.childCount > 0)
        {
            DestroyImmediate(transform.GetChild(0).gameObject);
        }
Comment

Unity Destroy All Children

void Update()
    {
    //put in any gameobject having children and enter playmode
        foreach (Transform child in transform)
        {
            Destroy(child.gameObject);
        }
    }
Comment

PREVIOUS NEXT
Code Example
Csharp :: how to reference function in unity 
Csharp :: unity copy list 
Csharp :: what type of variable is true or false in c# 
Csharp :: how to add reference to rigidbody 2d 
Csharp :: unity keycode 
Csharp :: convert string to date c# ddmmyyy 
Csharp :: c# return list 
Csharp :: rotate object to mouse position unity 
Csharp :: set object to random color unity 
Csharp :: c# check if string is only letters and numbers 
Csharp :: despicable me 
Csharp :: remove first character in a string c# 
Csharp :: c# font bold set 
Csharp :: unity dictionary check if key exists 
Csharp :: start the terminal from c# 
Csharp :: void to action c# 
Csharp :: c# error CS0515 
Csharp :: unity how get random color to material 
Csharp :: decimal to string c# 
Csharp :: how to print c# 
Csharp :: c# socket listen on port 
Csharp :: c# list of strings 
Csharp :: convert json to list object c# 
Csharp :: how to display doubles with trailing zeros in c# 
Csharp :: csharp 
Csharp :: c# check if 2d array position exists 
Csharp :: Unity Rigidbody how to set zero momentum 
Csharp :: c# list subfolders 
Csharp :: c# print multiplication table 
Csharp :: good food 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =