Efficiently and dynamically scale texture

I’m toying around in Unreal, loading up some Minecraft textures and applying them to cubes and whatnot. When I added, say, 40ish total cubes to my wall I noticed heavy lag spikes. I realized I need to ‘compress’ the wall into one big cube to reduce rendering pressure.


Now, the issue is that this will have to be dynamic through code later on, so I’m aiming on getting things doable in that aspect. I know that I can simply create a new material and change the UV coordinates to make them proper, but I’m not sure how I can do this through code. Is there perhaps a setting that automatically changes the scale factor of the UV tile based on how big the mesh is, or the likes?