Repeating texture without stretching

I’m pretty new to Unity and I want to make different sized ground blocks which have a material texture attached to them. Is it possible to make Unity automatically repeat the texture on different sized blocks so I wouldn’t have to set the tiling X and Y for each block manually? What kind of components and shaders should I use?

There are two options here:

  • Adjust the uv maps of the objects to reflect the tiling you want to achieve. Let’s say your block is 1x1, than your uv coordinates should range from (0,0) in one corner to (1,1) in the opposite one. If your block is 2x2, your uv coordinates should range from (0,0) to (2,2)
  • You could go for a custom shader solution based on the world space coordinates of your vertices instead of uv coordinates (if your boxes are axis aligned), alternatively you could use the vertex coordinates in object space but this requires the proper setup when modelling the blocks as well

Another option is to use ProBuilder, available in the package manager. That lets you create geometry in Unity and automatically tiles textures by the world space size of each face.

Thanks for the replies! I’ll try to make it work :slight_smile:

Just to echo bgolus, if you create a new shape in ProBuilder, you can edit it’s shape and size before clicking the build button. In that way you could create your walls of any size and they would still be at a scale of 1:1:1, allowing you to use that one material on all objects.