- Home /
Question by
Sycobob · Jul 11, 2013 at 09:27 PM ·
wwwloadimageintotexturemaintexture
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?
Comment
Best Answer
Answer by Brian@Artific · Jul 11, 2013 at 09:37 PM
For C#, you'll need an explicit cast:
www.LoadImageIntoTexture(renderer.material.mainTexture as Texture2D);
Thanks. This works. First time I tried it I must have messed up somewhere, because things went haywire.