- Home /
How do I return a reference to an object downloaded via a function?
Okay, I'm not sure if this is my brain having a meltdown or what, but I'm trying to get a reference to a downloaded object.. The DownloadSomethingFunction downloads an asset bundle. The problem I have is that any function that downloads something, requires a yield statement in order to allow the download however, this means that becomes impossible to return a value and thus be able to reference the object in question.
myDownloadedObject : GameObject=DownloadSomething();//My reference object
function DownloadSomething()
{
//do the download code here
while(downloading)
{
yield;
}
return (someDownloadedObject);//ERROR:RETURNS ARE NOT ALLOWED FROM GENERATORS!
}
Fingers crossed that my explanation makes some sense to somebody. Thanks in advance!
Comment