(1)準備
- 新規にCubeを作成
- 名前を「Box」に変更
- プレハブ化する

(2)スクリプトの作成
- 新規にC#スクリプトの作成
- 名前を「BoxGene」に変更
- 下記のコードを書いてチェック
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BoxGene : MonoBehaviour
{
public GameObject boxPrefab;
private void Start()
{
// 反復(繰り返し文)
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 5; j++)
{
Instantiate(boxPrefab, new Vector3(i * 1.2f, 0.5f, j * 1.2f), Quaternion.identity);
}
}
}
}
(3)設定
- 新規にCreateEmptyを作成
- 名前を「BoxGene」に変更
- これにBoxGeneスクリプトを追加
- 空欄にBoxプレハブをドラッグ&ドロップ

(4)再生
- 設定が完了したらゲーム再生
- 今回は、縦横5×5のボックスが等間隔で並べば成功です。
