I need to instantiate a wall of cubes in edit mode, using this script. It works in edit mode, but I’m trying to get it to work in 3D with no success. Any help?
@script ExecuteInEditMode()
var done : boolean = false;
var wall : GameObject;
var width : int = 6;
var height: int = 7;
var cube : GameObject;
var cubeWidth : float;
var cubeHeight : float;
var cubeLength : float;
function Update ()
{
if (!done)
{
for (var i = 0; i < height; i++)
{
for (var j = 0; j < width; j++)
{
for (var k = 0; k < width; k++)
{
var newCube = Instantiate (cube, Vector3(wall.transform.position.x+j*cubeWidth, wall.transform.position.y+i*cubeHeight ,wall.transform.position.z + k*cubeLength), Quaternion.identity);
newCube.name = ""+i+"-"+j + "-" + k; //names them after their position in the grid for easy referencing;
}
}
}
done = true;
}
}