Placing Multiple GO's In Selected Area

I am making a level editor for my game and i am currently trying to make a tool that when you hold down the mouse it places multiple gameobjects in the area selected filling it up. I’m not to sure how to go about this and have currently got the selection part working which allows me to call me function with the two vector3’s. I’m not sure i explained this well so heres a picture of what i mean:

My current function is structured like this:

    void PlaceSelectionOfBlocks(Vector3 _initialPos, Vector3 _endPos)
    {

    }

And i am using createBlock(Vector3 position) to create my block. Also everything is aligned to a grid.
Thanks.

I haven’t tested this, but something like this should work. Substitute your variables in for the parts with brackets.

 for (float x = Mathf.min(_initialPos.x, _endPos.x); x < Mathf.max(_initialPos.x, _endPos.x) - Mathf.Epsilon; x += [block length])
 {
    for (float z = Mathf.min(_initialPos.z, _endPos.z); z < Mathf.max(_initialPos.z, _endPos.z) - Mathf.Epsilon; z += [block width])
    {
      createBlock(new Vector3(x, [some y position], z));
    }
 }

You probably need the Epsilon part because float addition isn’t exact.