Hi, i’m trying to resize a texture from www but it doesnt work
var ResizedTexture = Texture2D;
url = "http://myurl";
var www : WWW = new WWW (url);
yield www;
ResizedTexture = www.texture; //Error : Cannot convert 'UnityEngine.Texture2D' to 'System.Type'
ResizedTexture.Resize(32,32,TextureFormat.PVRTC_RGB4,false); //Error : Can't resize to a compressed texture format
renderer.material.mainTexture = ResizedTexture;
Thanks for help
The reason is mentioned clearly there. You can not resize to PVRTC, actually you can not compress in realtime at all.
and for the resize part ? I did not succeed resizing a web image
Can you provide the actual code that you use?
The above one will never work cause you can’t use pvrtc
var ResizedTexture = Texture2D;
url = “http://myurl ”;
var www : WWW = new WWW (url);
yield www;
ResizedTexture = www.texture; //Error : Cannot convert ‘UnityEngine.Texture2D’ to ‘System.Type’
ResizedTexture.Resize(32,32,TextureFormat.RGB24,false);
renderer.material.mainTexture = ResizedTexture;
UnityScript always proofs again that its still some years away from being a real language and not some home hacker paradise of bugs, you could never have hit that bug in C# and that although the code otherwise looks basically the same
Change the first line to
var ResizedTexture [b]:[/b] Texture2D;
I have no more errors but the render is black.
If I remove this line : ResizedTexture.Resize(32,32,TextureFormat.RGB24,false); the texture appears with the original image resolution.
if not my cube is black
Eric5h5
September 20, 2011, 7:16am
10
Resize doesn’t mean scaling, if that’s what you’re trying to do. http://www.unifycommunity.com/wiki/index.php?title=TextureScale
–Eric
I want to resize a Large Texture to become a small texture
ex : image 512x512 downloaded on internet → icon 32x32
I add this line :
ResizedTexture.Apply();
after this
ResizedTexture.Resize(32,32,TextureFormat.RGB24,true);
No more dark but something like TV snow.
Any idea? Is it due to iOS development ?
Eric5h5
September 20, 2011, 10:39am
13
I already answered your question.
–Eric
cool it works, I think there is a problem of word, for me resize = résolution size, and scale = UV scale.
It seems to be inverted in Unity
Thanks a lot