Texture on Objects Same Size with Different Lengths

Hi there,

I have walls in my game that have a checkerboard type of texture. I am currently using tiling to repeat the texture but the effects are not what I want. I was wondering how to set it up so the texture appears the same height and width even if the object is bigger. I wish to use the same material as it is easiest.

What I mean is, if a wall is 100 units long and the texture is ten units long there should be ten repeated textures. But, if the wall is 20 units long there should only be two repeated textures.

Cheers,
Matt

I figured it out. I wrote a simple C# script and just attached it to each game object. It makes a instance of each material and computes the tiling.

using UnityEngine;
using System.Collections;

[ExecuteInEditMode]
public class TextureTilingController : MonoBehaviour {
	private float repeatEvery = 40f;

	// Use this for initialization
	void Start () {
		gameObject.GetComponent<Renderer>().material.mainTextureScale = new Vector2(gameObject.transform.localScale.z/repeatEvery, 1f);
	}
}