Road Texture Is Stretching

I’m building a city building game like Sim City or Cities XL. I’m working on creating a tool that will let players build roads. Although, im having an issue when the road stretches to reach the mouse cursor. The texture stretches as well. How can I make the texture tile instead of stretch?

Here is an example of what I have.

heres an example of what i’d like to acheive

You’d have to scale the texture coordinates as well.

The way I am seeing is to play with the UVs in the shader directly.
if your texture is good for 4 meters, you can do something like:
uv = roadLength / 4
And pass that road length as a shader property.

Hey man,
I don’t know if this is of any use to you (or if you’re still interested), but you can achieve a tiling effect like the roads in Cities XL by using an ObjectLinear shader. This basically projects your texture straight down onto your plane, the result of which won’t stretch like a standard UV mapped texture, but instead will tile quite nicely. The advantage here is that you don’t have to stretch each plane’s UVs individually, in fact you don’t even need to touch them. here’s a shader I made that I’m using in a tile based side scroller I’m working on:

Shader "Custom/ObjectLinear"
		_MainTex("Texture", 2D) = "" {TexGen ObjectLinear}
		Blend SRCAlpha OneMinusSRCAlpha
		Tags {queue = transparent}
		cull back
			Bind "vertex", vertex
			Bind "color", color
			Bind "texcoord1", texcoord

Remember, this shader will project down the z-axis, so for it to work on a plane, it has to be facing the z-axis. If you don’t, you’ll just get a line of pixels stretched across the plane. The standard Unity plane faces the y-axis, so it won’t work for that, but you probably won’t want to use it anyway since it has a lot of unnecessary geometry. So yeah, just create a plane in 3ds Max or Maya or something and rotate it’s pivot so the plane faces the z-axis. Import it into Unity (and check that it’s still facing the right direction since I’m pretty sure Maya flips the Z and Y axis’), create a new shader, put that code in I posted and, finally, chuck that shader onto your plane (as a GameObject). If you try stretching it, you’ll see that the texture will tile, not stretch. 'Hope this helps.