TimeBasedTrailRenderer

Author: Forest Johnson (Yoggy)

iPhone version by Niels Vanspauwen (nvsp)

C# version by xyber from Unity Forums

Description
I created this time based line renderer because I don't like how Unity's built in one works. As well as being time based instead of position based it also has some other features, like arbitrarily and independently sized color and scale fades, built in time out if it is needed, the ability to start and stop emitting at any time, and more optimization features so the line only has exactly as many segments as you want it to have or only as many as it needs to look good.

No doubt this is less WSIWYG and probably slower than the trail renderer or even line renderer but it generates better results in game.

Usage
Attach the script to any object that moves and should have a trail behind it.

What all the variables do:

Emit: Works just like on a particle emitter

Emit Time: automatically stop emitting after this many seconds, or leave at 0 for infinite

Material: the material to use on the line

Life Time: how long it takes for a line segment created at the front end of the line to fade out completely

Colors: Set the color fade with any number of colors

Sizes: Set the size fade with any number of sizes

Uv Length Scale: Set it real small unless your line has details along the x axis in the texture

Higher Quality UVs: this is the difference between using .magnitude and .sqrMagnitude. Doesn't matter much.

Move Pixels For Rebuild: The line mesh will not be rebuilt unless the line moves more than this many pixels on the screen. Can save a bit by not rebuilding on big lines that are not moving, and the camera is not moving much

Min Vertex Distance: Never make segments shorter than this

Max Vertex Distance: Never make segments longer than this

Max Angle: Never make angles between segments greater than this. Increasing it will make a faster but uglier line.

Auto Destruct: Destroy this object and the render object if we are not emitting and have no segments left.

JavaScript - iPhoneTimeTrail.js
The version above doesn't work on Unity iPhone. This one does. I did a couple of things to optimize it, but I'm sure there's more room for improvement.

C# - TimeTrail.cs
"Converted to C# and tested on iPhone." -xyber