How can I prevent texture stretching while scaling a mesh?

Is this the solution you are looking for?

I think my way it is a little easier dealing with modular building.