Adjust the direction of a texture in a dynamic drawing

From the code level, I draw the roof of the building based on the points.
The roof slopes are in different directions.

I have one type of tile texture.

When an object is added, the texture is in one direction all over the object (global).

I would like the tile to go downhill on each slope of the roof, corresponding to the direction of the roof.

How do I rotate the texture in this situation?

187035-qq1.png

So, if you are generating the mesh from code, then you are probably assigning each vertex an UV. That’s a position of that vertex on the texture. To flip a texture, just reverse those coordinates. Reversing both vertically and horizontally will rotate it 180 degrees.