1234567891011121314151617181920212223242526272829 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class cubeController : MonoBehaviour
- {
- public GameObject CubePrefab;
- //public List<GameObject> 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<MeshRenderer>().material.color = new Color(255, 0, 0, 1);
- CubePrefab.AddComponent<testMove>();
- 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();
- }
- }
|