Author Topic: Texture doesn't load properly for some reason  (Read 4165 times)

richardwood

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 8
    • View Profile
Texture doesn't load properly for some reason
« 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


anyone know why it become lines like that??
Thanks!

Ace

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 24
    • View Profile
Re: Texture doesn't load properly for some reason
« Reply #1 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?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Texture doesn't load properly for some reason
« Reply #2 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.

richardwood

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: Texture doesn't load properly for some reason
« Reply #3 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