Downloading while using @script ExecuteInEditMode() possible?

Hi, I’ am trying to download files while in edit mode but it never seems to achieve the download. (This works fine while in play mode)

@script ExecuteInEditMode();

var initRun:boolean=false;

function Update () {
	if (initRun==false)

function Init(){
    yield LoadAssetBundle("SomeBundle.unity3d");

Is this even possible? I get no errors just a message (my own debug) telling me that the bundle is currently downloading. Which it never seems to finish (unless its taking a VERY long time)

The coroutine scheduler isn't running in the editor, so you can't use coroutines (at least not the way like you do at runtime).

This question has already been asked and answered.

You have to check the isDone property manually. You can use your own coroutine scheduler for this, but if you don't understand how coroutines works internally you'd better just use an isDone-check in Update().


Btw: ExecuteInEditMode just causes to run the Update function when the editor updates itself (modifing something, changing view, ...). If you want a continous update in the editor you have to use the EditorApplication.update delegate. Keep in mind that this is an editor function and can not be used in scripts that run at runtime. If you want to include such a function in a runtime script you have to exclude it from compilation when you create a build. This can be achieved with the preprocessor directive #if UNITY_EDITOR:

    // editor stuff here