Пример #1
0
 IEnumerator SpawnCoroutine()
 {
     while (enabled)
     {
         int activeCount = EnemyObjectPooling.objectPool.FindAll(EnemyObjectPooling.IsActiveObject).Count;
         if (activeCount < maxSpawn)
         {
             GameObject enemy = EnemyObjectPooling.Spawn(objectPrefab);                                                  //creates and pools the gameObject.
             enemy.transform.position = gameObject.transform.position + (Vector3)Random.insideUnitCircle * spawnSpacing; //sets the spawn position to randomize inside the unit circle
         }
         yield return(new WaitForSeconds(spawnInterval));
     }
 }
 void Awake()
 {
     current = this;
 }