CubeController.cs 1.0 KB

1234567891011121314151617181920212223242526272829
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class cubeController : MonoBehaviour
  5. {
  6. public GameObject CubePrefab;
  7. //public List<GameObject> CubePrefabList;
  8. public void generateCubeSquare() {
  9. for (float x = -3; x < 2; x+=1.08f)
  10. {
  11. for (float z = 0; z < 5; z+=1.08f) {
  12. for (float y = 0; y < 5; y += 1.08f) {
  13. CubePrefab = GameObject.CreatePrimitive(PrimitiveType.Sphere);
  14. CubePrefab.GetComponent<MeshRenderer>().material.color = new Color(255, 0, 0, 1);
  15. CubePrefab.AddComponent<testMove>();
  16. Instantiate(CubePrefab, new Vector3(x, y, z), Quaternion.identity);
  17. }
  18. //Instantiate(CubePrefabList[Random.Range(0,CubePrefabList.Count)], new Vector3(x, 0, z), Quaternion.identity);
  19. }
  20. }
  21. }
  22. // Start is called before the first frame update
  23. void Start()
  24. {
  25. generateCubeSquare();
  26. }
  27. }