Tiling Texture for Modular pieces (non-square)

Hi, everyone !
I’m making a modular level in Unreal Engine 4 and having some problems with tiling the textures.
I texture them in Substance Painter. When I texture a square floor there aren’t any problems, but when it’s rectangular the seams are visible and it’s not tiled I was experimenting with UV and the settings in both UE4 and SP so now would like to get some help from you. I’d like to know how to make the proper UV layout and keep the ration.
I’m texturing rectangular wall and square floor and using the same material just for testing.