WebPlayer dataPath

Hello! I want to load an assetBundle from the server to economy the loading time. I searched a huge variety of topics and finally I read that the best method to load assetBundles is using the Application.dataPath (read it here).

First I create a Bundle, using BuildPipeline.BuildAssetBundle from documentaion (here).
Then I used this code to load it:

function Start () {

    var www = new WWW("file://" + Application.dataPath + "/myBundle.unity3d");

    Instantiate(www.assetBundle.mainAsset);

}

Worked fine for editor (my bundle was in the Assets folder) and also worked in .exe, when I changed the code like this: “file://” + Application.dataPath + "/…/myBundle.unity3d (my bundle was in the same directory, as the .exe file)

But nothing works in WebPlayer! I feel it should be very simple, but I really can’t understand what to change. Help me please, sure that this question is interesting for many people.

Thank you very much!

THE PROBLEM IS SOLVED! I added a GUI text, which shows the log to watch it in WebPlayer. So he wrote me, that the WebPlayer just didn’t had time to download my bundle on function Start! The action should be repeated, until the download is over. Through my ignorance, I missed yield www, from the assetBundle documentation. Just because didn’t knew it’s meaning. Hope this experience will help somebody like me. :slight_smile:

Here is my working code (a little modified):

var assetPath;

function Start () {

if (Application.isEditor)
{

assetPath = “file://” + Application.dataPath + “/Bundle.unity3d”;

}

else
{

assetPath = Application.dataPath + “/Bundle.unity3d”;

}

www = new WWW(assetPath);

yield www; // HERE YOU ARE!

Instantiate(www.assetBundle.mainAsset);

}

As I understand it, Web Player can’t use Application attributes/functions/etc. They need to be stored on a remote server and accessed via http:// instead. This was driving me nuts too.