Editor Scripting - Override Scaling

I have a script to create a cube procedurally (it'll be more sophisticated than a cube eventually!). I have added this to the editor menu - all this works well. What I need to do now is to adjust the mesh when scaling - either by overriding the scaling gizmo or by creating a new gizmo type. Any suggestions on the easiest way to do this?

(To give some context, I want to procedurally create a very simple house. As it's scaled along x or z I want to insert more windows. As it's scaled on y, I want to add more floors.)


I'm not really sure what the best way to do that would be, but what comes to mind is, on a per-update basis, compute the number of windows, floors, etc. based on the current scale, and then rebuild the mesh if and only with those values have changed with respect to the previous update.

(There might be some way to interact with the gizmo in a more direct way, but if so I don't know it off the top of my head.)

[Edit: That doesn't really address all the possible issues involved though, since you'd probably want more control over the behavior than that (e.g. house size changes as scale is changed, but windows, doors, floors, etc. all maintain the same relative size and are simply added and removed as needed). Maybe a better solution would be to create your own scene-view interface using picking and so on.]