Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.04 KB | None | 0 0
  1. public class GridGen : MonoBehaviour
  2. {
  3.  
  4.     [SerializeField] private GameObject theCube; //old
  5.     [SerializeField] public float cubeSize = 1f;
  6.     [SerializeField] public Vector3Int gridData = new Vector3Int(0, 0, 0);
  7.  
  8.     //[NonSerialized] public int[,,] cubeArray = new int [10, 10, 10]; //old
  9.     private Data3D[,,] cubeArray = new Data3D [10, 10, 10]; //new
  10.  
  11.     // Start is called before the first frame update
  12.     void Start()
  13.     {
  14.         GenerateCubes();
  15.         DestroyCubes();
  16.     }
  17.  
  18.     // Update is called once per frame
  19.     void Update()
  20.     {
  21.            
  22.     }
  23.  
  24.  
  25.     void GenerateCubes()
  26.     {
  27.         print("GenerateCubes works");
  28.                        
  29.             for (int z = 0; z < cubeArray.GetLength(2); z++)
  30.             {
  31.                 print("loop1 works");
  32.                 for (int x = 0; x < cubeArray.GetLength(0); x++)
  33.                 {
  34.                     print("loop2 works");
  35.                     for (int y = 0; y < cubeArray.GetLength(1); y++)
  36.                     {
  37.                         GetComponent<Data3D>().CreateCube(gridData);
  38.                         print("loop3 works"); print("gridData: " + gridData);
  39.                        
  40.                         gridData.x ++;
  41.                         if(gridData.x >= 10){gridData.x = 0;};
  42.                     }//cols for
  43.  
  44.                     gridData.y ++;
  45.                     if(gridData.y >= 10){gridData.y = 0;};
  46.                 }// rows for
  47.  
  48.                 gridData.z ++;
  49.                 if(gridData.z >= 10){gridData.z = 0;};
  50.             }// zee for
  51.     }//end GenerateCubes
  52.  
  53.     void PrintArray()
  54.     {
  55.         for (int z = 0; z < cubeArray.GetLength(0); z++)
  56.             {
  57.                 for (int x = 0; x < cubeArray.GetLength(1); x++)
  58.                 {
  59.                     for (int y = 0; y < cubeArray.GetLength(2); y++)
  60.                     {
  61.                         //int s = cubeArray[x, y, z];
  62.                         //print(x + " " + y + " " + z + " : " + s);
  63.                     }
  64.                 }
  65.             }
  66.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement