using System.Collections; using System.Collections.Generic; using UnityEngine; public class cubeController : MonoBehaviour { public GameObject CubePrefab; //public List CubePrefabList; public void generateCubeSquare() { for (float x = -3; x < 2; x+=1.08f) { for (float z = 0; z < 5; z+=1.08f) { for (float y = 0; y < 5; y += 1.08f) { CubePrefab = GameObject.CreatePrimitive(PrimitiveType.Sphere); CubePrefab.GetComponent().material.color = new Color(255, 0, 0, 1); CubePrefab.AddComponent(); Instantiate(CubePrefab, new Vector3(x, y, z), Quaternion.identity); } //Instantiate(CubePrefabList[Random.Range(0,CubePrefabList.Count)], new Vector3(x, 0, z), Quaternion.identity); } } } // Start is called before the first frame update void Start() { generateCubeSquare(); } }