Texture tiling based on Object size/scale

I want to create a ground plane that can be scaled to any size and maintain the same texture size on the surface without having to change the material tiling every time.

To give an example. Make a plane 1000x1000x1000. Add a grid 100x100 pixel texture and change the tiling to 1000 on both x and y. Now when you scale the plane the texture changes size relative to everything else.

How do I mitigate this effect?


I wrote an article, Texture Tiling based on object Size/Scale in Unity, that goes over two methods to get this feature.

Basically you look for changes in scale and adjust the tiling accordingly. If you want this in the editor, make the script ‘execute in editor’. Note that affecting the tiling is per-material so if that same material is used elsewhere, it will mess with them. The other option is to play with UV’s but I wouldn’t.

You could use this: Unity Asset Store - The Best Assets for Game Making

And change the plane’s size instead of scale. Except you don’t want to do it at run time very often, because it regenerates the mesh. It’s an out-of-the-box implementation of the second method you describe. It has an advantage of not taxing your material count.

Is there a way to get method 1 in your article to work in all 3 directions and not just on the top surface?
I want to make a rescalable wall.