Search Unity

[url]WWW.texture[/url] on error loading image or no image present

Discussion in 'Scripting' started by Marc, Nov 30, 2007.

  1. Marc

    Marc

    Joined:
    Oct 4, 2007
    Posts:
    499
    Greetings.

    I am using WWW class to download textures from the web, but if the server replies an error in html for instance. The texture property of the WWW class will return a question mark texture. What ever happen to just returning null, weird.

    Oh well my question is: Is there a way to detect on that property if i got the question mark texture? so i can set another texture myself aka. simulate a null return.

    Cheers,
    Marc
     
  2. Brian-Kehrer

    Brian-Kehrer

    Joined:
    Nov 7, 2006
    Posts:
    411
    I think this is it?

    Code (csharp):
    1.  
    2. var www : WWW = new WWW(url);
    3. yield www;
    4. if([url]www.error[/url]){
    5. print("your connection sucks");
    6. }
    7.  
     
  3. Marc

    Marc

    Joined:
    Oct 4, 2007
    Posts:
    499
    Well problem is that i dont get an error downloading cause my connection suck. I just get a html error response like texture not found, so is not an error in that sense for the WWW class.

    Problem is i have no way to detect if i get this back except checking if the texture contained in the texture property is the question mark :/ or inspecting the bytes. Would be so much easier if the texture property was just set to null if there was no texture downloaded.
     
  4. Brian-Kehrer

    Brian-Kehrer

    Joined:
    Nov 7, 2006
    Posts:
    411
    I see--maybe the unity guys have a better idea--
    but here are my bad ideas.
    Is the url correct?
    Is it possible to check file size?
    Can you detect the failure on the server, and have unity ask if the transfer was successful? -- i guess not since it never connects...
     
  5. Marc

    Marc

    Joined:
    Oct 4, 2007
    Posts:
    499
    Sorry think i missed a word in my first sentence above. I do get a connection and a server reply. The server reply should if all goes well be a texture. This works.

    BUT when the server for some reason cant send me the image i get a HTML error page returned as i should, now this will not show up as an error on the WWW class as there is in term no error i just got different type of content back.

    Now when i access the www.texture property it contains the ?-texture, and the www.error is null, so i have no way to detect this except inspecting all bytes in www.bytes which i think is overkill but is the only way i can do it atm.
     
    Menion-Leah likes this.