A way to scale a grid material on a cube from the center of the plane

Alright, this is a question I don’t know exactly how to phrase so please excuse any wrong terminology.

I have a cube that has a grid material on it. I want to scale the cube to a larger size (which I’ve accomplished - yay!). The initial problem with this was that the material would stretch, rather than repeat. Again, this is something I solved to a degree.

Right now I am recalculating the UV’s for each side of the cube every Update() while I’m lerping to the larger size. This works great except that the material is applied from the (0,0) point of the UV and I would like it to come from the center of the cube face. Basically, I’m trying to make the grid lines stay still while expanding. Is this possible? Am I over-complicating this?

It seems to me that you shouldn’t need to manipulate UVs to accomplish this. I’m fairly confident you can achieve what you’re after by manipulating the material’s tiling and offset properties based on the localScale of the object(s). Your approach is not invalid, but it does seem much more complicated than necessary.

Ultimately you’re doing a similar math operation to get the intended behavior, but I would think it’d be a little easier to figure out this way.

See mainTextureOffset and mainTextureScale