Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: richardwood on August 23, 2014, 02:30:06 PM

Title: Texture doesn't load properly for some reason
Post by: richardwood on August 23, 2014, 02:30:06 PM
Hello, I'm currently stuck on this part. Basically I want this box to load image from url

This is my snippet
  1. void Start () {
  2.         StartCoroutine(SetAvatar());
  3.         }
  4.  
  5. IEnumerator SetAvatar()
  6.     {
  7.         while (true)
  8.         {
  9.             if (avatarLoaded == false && PlayerObjectScript.display_pic != "")
  10.             {
  11.                 Texture2D ava = new Texture2D(50, 50, TextureFormat.DXT1, false);;
  12.                 var www = new WWW(PlayerObjectScript.display_pic);
  13.                 www.LoadImageIntoTexture(ava);
  14.  
  15.                 this.GetComponent<UITexture>().mainTexture = ava;
  16.                 avatarLoaded = true;
  17.             }
  18.             else
  19.             {
  20.                 yield return null;
  21.             }
  22.         }
  23.     }
  24.  
PlayerObjectScript.display_pic this var is this link: http://puu.sh/3c74g.png


This is the result
(http://puu.sh/b4PEv/34d11127ae.jpg)

anyone know why it become lines like that??
Thanks!
Title: Re: Texture doesn't load properly for some reason
Post by: Ace on August 23, 2014, 07:03:45 PM
Hi

I've had issues like this before too. I noticed if I had a texture sheet above 2048x2048 this came up.

Is your texturesheet bigger than that?
Title: Re: Texture doesn't load properly for some reason
Post by: ArenMook on August 23, 2014, 08:14:10 PM
Is the texture actually DXT1-compressed? My guess is that it isn't. You should try specifying ARGB32 instead.

Also, you might want to yield until the download completes, and only then set the mainTexture.
Title: Re: Texture doesn't load properly for some reason
Post by: richardwood on August 23, 2014, 09:21:07 PM
thank you, that's fixed it, changing the compression, and wait till the www has done downloading the data