- Home /
Threading in Unity Editor
I would like to call Lightmapping.BakeAsync, wait it to finish (without freeze the editor) and do something else when it's done. As long I can't call Unity API from any thread but the main one, how could I achieve that?
[MenuItem("Bake/Bake")]
public static void Bake() {
// Do something
Lightmapping.BakeAsync();
// Wait till it's done.
// Another Unity API call
}
Did you ever solve this? I'm having this exact issue. Why can't a $$anonymous$$enuItem run things on the main thread? I've got no access (that I'm aware of) to any Update method or OnGUI or anything, since $$anonymous$$enuItem methods are static.
Answer by Eric5h5 · Oct 10, 2012 at 03:40 AM
Check Lightmapping.isRunning in a coroutine.
Coroutine in Unity Editor? I can't find documentation about it, but all answers here says it can't be done.
Also, StartCoroutine is not static and I'm just calling a static method from the menu.
Thank you, but I don't have an EditorWindow, it's just a static method call from the menu.
Couple of years late here, but if you want to run a coroutine from an editor script, you just have to subscribe to EditorApplication.update and manually iterate through your coroutine in the subscribing function.
Your answer

Follow this Question
Related Questions
How do you stop multithreading in editor? 1 Answer
How to clear UnityEditor memory? 0 Answers
Some GameObjects not visible in android build but work fine in the editor? 0 Answers
Constant error : SaveSnapshot called without previous call to MakeSnapshot 1 Answer
Loading a large external image to texture without freezing the game? 1 Answer