How to assign material into Trail Renderer's material Component?

I’ve Instantiate a Game Object and add a TrailRenderer Component into it. How to assign a material into the Trail Renderer in scripting??? The Material is called “matLine” in Materials Project Folder.

I’ve googled it but no luck. This is one of the basic things in Unity, yet I can’t find the solution. :rage:

Your help is deeply appreciated.

you mean, like renderer.material?

var tr : TrailRenderer=myObject.AddComponent(TrailRenderer);
tr.material.color = Color.red;

TrailRenderer is an extension of Renderer. Renderer has a base property called material. You access it just like any other renderer.