Generating platforms one after another

How can I make a tile generator, which can generate one tile, and then another right after it, no matter the position in the x, y and z axis?

Instantiate the tile at the previous tile position and translate it across half the width.

//Assign the first tile here.
Transform lastTile;

//function or coroutine.
{
    Transform newTile;
    newTile = Instantiate(tilePrefab, lastTile.position, lastTile.rotation);
    newTile.Translate(lastTile.localScale.x / 2, 0, 0);
    lastTile = newTile;
}