How to instantiate in edit mode?

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;
    }
}

Look at this previous answer of me to see an example, just ignore the part where I set up joints. It’s basically your script, but @script ExecuteInEditMode() on the top and the condition (in your case it’s an input, which doesn’t work in the editor, remember that!) is the push of a button in the inspector.

You can also just call a normal function (not Update), and use:

EditorUtility.InstantiatePrefab(...)

to create the cubes using Joashua’s arrangement.