Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Web Player and WWW class

Discussion in 'Editor & General Support' started by irataxy, Sep 14, 2007.

  1. irataxy

    irataxy

    Joined:
    Sep 14, 2007
    Posts:
    21
    Hello,

    I am having a problem with the Web Player. I assume the problem is coming from the WWW class, but am not certain.

    I am making a game that loads plain text files for different levels from a web server. The user can press a button to advance or go back levels, calling the following function:


    function readWebFile()
    {
    var levelURL="http://www2.hawaii.edu/~ncook/levels/level" + currLevel + ".xsb";
    transform.Find("Level").GetComponent(UpdateLevel).level[0] = currLevel;

    // Start a download of the given URL
    var download : WWW = new WWW (levelURL);


    yield download; // Wait until the download is done
    if (download.error)
    {

    print("There was an error downloading the URL: " + download.error);
    levelLoaded = 0;

    }
    else
    {
    //work with the data
    }
    }

    This works flawlessly in the Editor. I have never had a problem. When I use the Web Player, however, it does one of the following:

    1) The level data doesn't load because the corresponding game data does not show on the screen.
    2) Safari crashes.

    Sometimes, the level does load. I then advance three or four levels quickly (via button presses) and then the next level does not load. Again, I have never had any problems doing this in the Editor.

    I have tested this on a 1 Ghz Powerbook G4 with 512 SDRAM on OSX 10.4.10 and Safari 2.0.4 with the latest Unity plug-in. I have also tested it on a PowerPC G5 with 8 GB SDRAM on OSX 10.4.10 and Safari 2.0.4 (with the latest plug-in) and Firefox version 2.0.0.6 with similar results.
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Yeah, the WWW class currently has problems with web players/widgets, since it's done differently than the stand-alone/editor; it's a known issue. I've worked around it myself by 1) checking to see if the result is null, and if so, keep trying to download until the result is not null and 2) sending some extra "padding" data that I disregard once downloaded, since sometimes the data is corrupted at the end. So far this has worked perfectly.

    --Eric