Using WWW.LoadImageIntoTexture with material.mainTexture

According to the script documentation for WWW.LoadImageIntoTexture, I should be able to use it with something like

www.LoadImageIntoTexture(renderer.material.mainTexture);

however, in Unity 4.1.4f1 this is a syntax error. mainTexture returns a Texture and LoadImageIntoTexture is expecting a Texture2D. What gives? Is there some way to copy a downloaded texture directly into mainTexture on a material?

For C#, you’ll need an explicit cast:

www.LoadImageIntoTexture(renderer.material.mainTexture as Texture2D);