Can we flush output to the Console window?

I have an editor script that rips through the scenes and objects in our game, creating asset bundles.

It’s kind of a lengthy process, so I added code to output the name of the asset bundle to the Console window as it creates each one.

However, we don’t get any output until after the entire process is complete.

Is there a way to flush the output to the Console window via C# script code?

Thanks!

1 Like

Too bad nobody has answered this. I still need it in 2015!

I was as well looking for an answer. Could not find any explanation when the output is flushed or how to trigger it.

The editor needs a chance to update its UI in order to show anything in the console window. So if your script is blocking the main thread… well there’s nothing the editor can do except wait for your script to finish.

So you actually need a coroutine for this. The problem here is the standard coroutine doesn’t work in editor scripts, as they need to hook into some update function.

The solution is to create your own coroutine solution for the editor. There are a few sample EditorCoroutine source code out there, like this or this.

(Note to people in the future (hi!) – if these links are dead by the time you read this, just google “EditorCoroutine” to find other and similar hits)

1 Like

Can the Editor use the 4.6 runtime? If so, could you not async/await and log to console in between?

10 years later and we’re still waiting on an easy way to flush the console :stuck_out_tongue:

1 Like