How do I access a different material via Javascript?


Sorry for the Newbie question!

I’m stuck on something really simple. I can’t seem to change materials on an object. I’m trying ot change between the below materials on keypress “G”. Both materials are in my materials folder, but l can’t seem to get the script to load the “TestButtonOn” material, …

Materials, …
TestButtonOff (already assigned)

Code, …

   function Update () 
   		var newTexture : Texture;
		newTexture = Resources.Load("TestButtonOn");
                renderer.material.mainTexture = newTexture;
            	print ("My Texture is " +;


i dont know if that will work, but you can try

newTexture = Resources.Load("TestButtonOn", Texture);

as the Resources.Load receives 2 params, the path of the image and the type to be cast.