Scaling/Offsetting a texture based on object size to match up with other objects

I have a 3d block. I can change the blocks scale in all 3 dimensions during runtime. Currently, the block has a material with a texture applied to it. Naturally, when I scale the block, the texture stretches with it.

I would like for the texture to be uniform, regardless of the block size. So if I place two blocks of different size next to each other, I’d like the textures to match up.

Normally, I’d work out something like this by myself, just playing around with different values, however, I haven’t really messed around with textures, at all, so I find them a bit confusing. For instance, I realize a texture is an image with 2 dimensions, but my objects scale in 3 dimensions, and I can’t wrap my head around how to scale the texture properly in this circumstance.

Any help on this would be appreciated.

For a block, something along these lines should work:

using UnityEngine;
using System.Collections;

public class ScaleTexture : MonoBehaviour {
    void Update() {
        float scaleX = transform.localScale.x;
        float scaleY = transform.localScale.y;
        renderer.material.mainTextureScale = new Vector2(scaleX, scaleY);
    }
}

Solved the whole problem with this:

This is what I wanted all along.