using System.Collections; using System.Collections.Generic; using UnityEngine; public class Map2 : MonoBehaviour { private GameObject[] materialBox2; void Start() { // ポイント materialBox2 = Resources.LoadAll<GameObject>("BoxM"); print(materialBox2[0]); print(materialBox2[1]); print(materialBox2[2]); // ↓上記と同じ処理をforeachを使って実装 foreach(var i in materialBox2) { print(i); } } }