static int GetAsteroidCount(GameObject obj, Asteroid.TYPE type) { int count = 0; foreach (Transform child in obj.transform) { Asteroid asteroid = child.gameObject.GetComponent <Asteroid>(); if (asteroid != null) { count += GetAsteroidCount(asteroid.VisObject, type); if (asteroid.type == type) { count++; } } } return(count); }
public int AsteroidCount(Asteroid.TYPE type) { return(GetAsteroidCount(this.gameObject, type)); }