How can I create dynamically objects (cubes) from one wall to the other in code in Unity? Such here:

2 Answers
It's funny that Unity guys have written an example which looks like exactly the same thing you are trying to achieve :)
1 Comment
Kora Kora
Thank you a lot :) Do you know how can I create empty space between cubes?
You can instantiate a prefab with 2 for sentences.
public GameObject objToCreate;
void Start ()
{
//2 for sentences to create a vidirectional array
for(int i = 0; i<5;i++){ //for move on Y
for(int j = 0; j<5;j++){ //for move on X
Instantiate(objToCreate, transform.position,transform.rotation);
transform.Translate(1f,0,0); //Move on X
}
transform.Translate(0,1f,0); //When fill X translate on Y and start again
transform.Translate(-5f,0,0); //Reset out transform position 5 units as set in the first for sentence
//For mor space between objects just change the values in Translate function
}
}