I know that using transform.childCount will print the number of child in a parent. but it only prints one. How to will I know the number of children when it is dynamically changing at a runtime?
here's my code
public class StructureChecker : MonoBehaviour {
void Start(){
update();
}
public void update(){
foreach (Transform t in transform.parent) {
Debug.Log (t.transform.childCount);
}
if (transform.childCount == 0) {
Debug.Log ("Structure is full");
} else {
Debug.Log ("Still has child");
}
}
↧