How could I instantiate to a GameObject variable in a class?

class GaragesClass {

    var unit : GameObject = new GameObject();

}

var unit : GameObject;

private var floors : int = 12;
private var garages : GaragesClass[] = new GaragesClass[floors];

private var baseHeight : float = -2;
private var height = 16.66666;

function Awake () {

    for (var i : int = 0; i<floors; i++) {
        garages_.unit = Instantiate(unit, Vector3(0, baseHeight*height+i*height, 0), Quaternion.identity);_
 *}*
*}*
*```*
*<p>Instantiating gives the error "Object reference not set to an instance of an object"</p>*

You just forgot to instantiate your array elements. add this line

garages *= new GaragesClass();*
*```*
*<p>at the beginning of the for loop, and it's gonna work.</p>*