Attempting to fade 3d text

Firstly: I know this has been documented, and answered before, as evidenced here among numerous other places. The issue isn’t a lack of help, it’s my complete newness at coding. I’m attempting to code a fade in and fade out for 3d text. I’ve placed the code from here into an empty game object in my scene, and am attempting to attach the following code into the 3d text:

Fade.use.Alpha(GetComponent(TextMesh).renderer.material, 0.0, 1.0, 2.0);
{


function ()
{
for(i=1;i>0;i++)
{
yield WaitForSeconds(3.0);
}
}

Entering into this, I knew I would code something wrong, as my entire coding education so far has been stumbling along until something works, and then asking for help, and hoping that the advice not only fixes the current issue, but that I retain why the advise worked. So I guess I’m asking if someone can tell this noob what I need to add to my script to actually make it, you know, a script. Thanks, and God bless.

Here’s an example I came up with for your question. Simply attach this to your 3DText Object, then use the ‘E’ key to toggle the fade. I made this only fade out if alpha is 1.0, and only fade in if alpha is 0.0. There are many different ways of doing this but hopefully this will get you going.

Here’s a C# Example

using UnityEngine;
using System.Collections;

public class Example : MonoBehaviour 
{
	bool fadeIn = false;
	bool fadeOut = false;
	float fadeSpeed = 0.01f;
	float minAlpha = 0.0f;
	float maxAlpha = 1.0f;
	Color color;
	
	void Awake()
	{
		color = renderer.material.color;	
	}
	
	void Update()
	{	
		renderer.material.color = color;
		
		if(fadeIn && !fadeOut)
			FadeIn ();
		
		if(fadeOut && !fadeIn)
			FadeOut ();
		
		if(color.a <= minAlpha)
		{
			fadeOut = false;
			if(Input.GetKeyDown (KeyCode.E))
			{
				fadeIn = true;	
			}
		}
		
		if(color.a >= maxAlpha)
		{
			fadeIn = false;
			if(Input.GetKeyDown (KeyCode.E))
			{
				fadeOut = true;	
			}
		}
	}
	
	void FadeIn()
	{
		color.a += fadeSpeed;
	}
	
	void FadeOut()
	{
		color.a -= fadeSpeed;
	}
}

And here is a Javascript example of the same thing.

#pragma strict

var fadeIn : boolean;
var fadeOut : boolean;
var fadeSpeed : float = 0.01;
var minAlpha : float = 0.0;
var maxAlpha : float = 1.0;

function Update()
{  	
	if(fadeIn && !fadeOut)
		FadeIn ();
	
	if(fadeOut && !fadeIn)
		FadeOut ();
	
	if(renderer.material.color.a <= minAlpha)
	{
		fadeOut = false;
		if(Input.GetKeyDown (KeyCode.E))
		{
			fadeIn = true;  
		}
	}

	if(renderer.material.color.a >= maxAlpha)
	{
		fadeIn = false;
		if(Input.GetKeyDown (KeyCode.E))
		{
			fadeOut = true; 
		}
	}
}

function FadeIn()
{
	renderer.material.color.a += fadeSpeed;
}

function FadeOut()
{
	renderer.material.color.a -= fadeSpeed;
}