Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

4
How to get all children of parent gameobject?
Post Flair (click to view more posts with a particular flair)
Post Body

When game starts I want to add X gameobject as a child of some Y parent gameobject,

But before it is added, I want to check if there is already any child gameobject. If there is then I want to destroy it and add new X gameobject. I made some code but it seems not to work as I want it to.

if(levelsParent.transform.childCount > 0)

l = levelsParent.GetComponentsInChildren<Transform>();

foreach (Transform li in l)

{

if(li)

{

GameObject.Destroy(li.gameObject);

}

}

GameObject lt = Instantiate(levelTemplates[cardLevel - 1]);

Author
Account Strength
80%
Account Age
10 years
Verified Email
Yes
Verified Flair
No
Total Karma
93
Link Karma
14
Comment Karma
25
Profile updated: 4 days ago
Posts updated: 1 year ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
3 years ago