yield statment

I’m trying the MeshSerializer package from the Unity Wiki and it’s failing because it’s trying to access data that hasn’t been downloaded yet.

Looking at the code I can see there should be a yield statement in there:

static function ReadMeshFromUrl( url : String ) : Mesh
{
    var download = WWW(url);
    yield download;
    if( download.error )
    {
        print ("Error downloading mesh from " + url);
        return null;
    }
    
    var data = download.data;

However when this is compiled I get a :
error BCE0101: The return type of a generator must be either ‘System.Collections.IEnumerable’ or ‘Object’.

My code matched the use of yield in the Unity documentation example - what am I doing wrong?

I believe due to the way coroutines work internally, you can’t make them a static method. Try removing “static” and making that class a singleton.

It would be great to file a bug on this so at the very least a better compiler error message can be given.

Cheers,
-Jon

That’s solved the problem, thank you for your help.