(Unity)コルーチンの使い方(1秒ごとにブロックを生成して並べる)

(スクリプト)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BlockGene2 : MonoBehaviour
{
    public GameObject blockPrefab;

    void Start()
    {
        StartCoroutine("Gene");
    }

    private IEnumerator Gene()
    {
        for (int i = 0; i < 5; i++)
        {
            Instantiate(blockPrefab, new Vector3(i, 0.5f, i), Quaternion.identity);

            yield return new WaitForSeconds(1.0f);
        }
    }
}