apply different texture in a range

I want to apply different texture in my terrain, I create a terrain with proceduralmeshcomponenet , the UV-Vector divide the terrain in square, the idea is different square have diferent texture , the texture is determinate by a funtion but i don´t know how apply the texture to the square. i read about setMaterial but i think not work.