Liner renderer using script?

i need to make the line from my camera point to mouse point this line should move when i move the mouse cursor. I dont know how to do this help me to do this.

create a trial renderer and attach the following script to it.

TrailRenderer _trial;
// Use this for initialization
void Start () {

	_trial=GetComponent<TrailRenderer>();
	_trial.enabled=false;

}

// Update is called once per frame
void Update () {
	if(_trial.enabled)
    {		
        Vector3 temp=Input.mousePosition;		
		Vector3 tempPos=Camera.main.ScreenToWorldPoint(new Vector3(temp.x,temp.y,transform.position.z-Camera.main.transform.position.z));
		transform.position=new Vector3(tempPos.x,tempPos.y,tempPos.z);
    }
}


void OnGUI()
{
	
	
             // add you condition  when this should not work  

             /* if(unwantedPlace)
                {
                    _trial.enabled=false;
                    return;
	    }
             */
            // this below code is to make it appear only whn you click and drag, remove it if you want it always
	if(Event.current.type==EventType.MouseDown)
	{
		_trial.enabled=true;
	}
	
	
	if(Event.current.type==EventType.MouseUp)
	{
		
		_trial.enabled=false;
		
	}
	
}

Note that you have to tweak you trial renderer though to get it work.