(スクリプト)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyGene : MonoBehaviour
{
public GameObject[] enemyPrefabs;
// ★ポイント
private int num ;
void Start()
{
StartCoroutine(Gene());
}
private IEnumerator Gene()
{
while (true)
{
// ★ポイント
num += 1;
// ★ポイント
for (int j = 0; j < num; j++)
{
Instantiate(enemyPrefabs[1], transform.position, Quaternion.identity);
yield return new WaitForSeconds(0.2f);
}
yield return new WaitForSeconds(0.5f);
}
}
}
(実行結果)