- Home /
Changing format of downloaded texture
I want to download a file image through UnityWebRequest then use it as texture. For this particular project, I have a huge image with resolution of 5000 * 3000 something and I want to keep it that way. The problem is when I download it and attach the texture to a shader its blue. I believe if I could play around with the import setting I could make it work, but I don't know how to do that through script for downloaded textures.
Answer by vasupol11 · Aug 18, 2017 at 11:02 AM
IEnumerator imageStream(string url){
Texture2D tex;
tex = new Texture2D(5376,2688);
WWW www = new WWW(url);
yield return www;
byte[] k = www.bytes;
tex.LoadImage(k);
tex.Apply();
Material x = GetComponent<MeshRenderer>().material;
x.SetTexture("_MainTex", tex);
}
I found the answer. I had a specific resolution because it's for 360 image, the problem for me was the loading texture initially gave me a very pix-elated image. this works great and the image comes with full quality, but becareful of the bytes function, you have to delete it manually and I havnt done it here