Yield Problems

Helo, i’m trying to use WWW to get an assetbundle on a local server. The problem is when i try to use “yield” to get the asset i get the following error message :

Failed to load asset bundle

Here’s the code :

//Default dimensions for the text area
    public int defWidth = 500;
    public int defHeight = 25;
    //Object on which the material will be applied
    public GameObject obj;
    //Used to check if the url was changed | avoid reloading the file
    private string lastUrl = "Enter the adress";
    //Te actual variable containing the url of the file
    private string url = "Enter the adress";
    //The variable containing the adress of WWW method
    private WWW wwwTest = null;
    //The variable containing the adress of the material
    private Material mat;

private void LoadPart(string link)
        if (lastUrl != link)
            if (wwwTest.error != null)

    private IEnumerator GetAsset(string link)
        AssetBundle ab;
        wwwTest = new WWW(link);
        yield return wwwTest;
        ab = wwwTest.assetBundle;

    void OnGUI()
        int lastYPos = 0;
        int textAreaHeight = defHeight;
        int textAreaWidth = defWidth;
        int buttonWidth = 50;
        int buttonHeight = 20;
        url = GUI.TextField(new Rect((Screen.width - textAreaWidth) / 2, lastYPos, textAreaWidth, textAreaHeight), url);
        lastYPos += textAreaHeight;
        if (GUI.Button(new Rect((Screen.width - buttonWidth) / 2, lastYPos, buttonWidth, buttonHeight), "Load"))
        lastYPos += buttonHeight;

This is only a testing code to see how assetbundles work, but so far i failed to understand how to use it with or without coroutines.

Edit : this error is the same i had when i wrote the code without a coroutine. I don’t uderstand why it fails to load, when i try to import the assetbundle from the editor it works fine. In there is only a material called “Ananas” with texture of ananas skin.

Wow, i don't want to believe this, but it seems some people don't even read the code before answering. As it turns out, the yield wasn't the problem. I checked every part i yielded and everything went fine, even the size of the file loaded was the same. The only thing was the failing of loading. After much checking, it seems i was building my bundles wrong, and that's why WWW couldn't load them.

Just saying in case someone else has the same problem, if :

  • isDone = true

  • error = null

  • size = size of the bundle

then the problem is most likely the bundle itself.

You’re not yielding on the GetAsset coroutine, as the error says.