Created
February 12, 2015 13:21
-
-
Save litvil/2abf6e289db9e7e9270d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int childs = transform.childCount; | |
for (int i = childs - 1; i > 0; i--) | |
{ | |
GameObject.Destroy(transform.GetChild(i).gameObject); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
your code has bug.
this is better:
for (int i = 0; i < transform.childCount; i++)
{
GameObject.Destroy(transform.GetChild(i).gameObject);
}