I’m playing with arrays so i can get a little more comfortable with them.
as a test i wrote this bit of code it is supposed to create an array of 16x 16 cubes
But it seems to create more and more over the top of each other like I’m iterating the whole process but I’m not sure why?
sing UnityEngine;
using System.Collections;
public class ObjArray : MonoBehaviour {
public int ArraySize = 16;
public GameObject cube;
// Use this for initialization
void Start () {
cube = GameObject.Find("PREFAB_cube");
}
// Update is called once per frame
void Update () {
GameObject [ , ] cubes = new GameObject [ ArraySize , ArraySize ];
for(int i = 0; i < ArraySize; i++)
{
for(int j = 0; j < ArraySize; j++)
{
cubes[i,j] = (GameObject) Instantiate (cube ,
new Vector3(i,j,0) ,
Quaternion.identity);
}
}
}
}