Perform actions in the editor without freezing it?

I have a very time-consuming task that I execute in the editor in Edit Mode using a context menu. This freezes my editor and I wonder how I can perform an action in the editor, like calling a function, that runs in the background taking performance and resources, but not freezing the editor because it doesn’t have to complete in a single frame update.

I know of Coroutines using the yield keyword allowing such a behavior, but if I read the manual correctly, I always need a GameObject that the coroutine is attached to. Is there no way to perform something in the editor without having to attach it to a GameObject or a MonoBehavior instance? I would like to not create a dummy GameObject for the purpose of having a coroutine.

What is a recommended way to perform (automated) actions in the editor that should not be forced to complete in a single frame update and therefore not freeze the editor?

@Ardenian

I came across this while doing some editor windows. Never used this, but here is a link, maybe it is useful:

https://docs.unity3d.com/Packages/com.unity.editorcoroutines@0.0/api/Unity.EditorCoroutines.Editor.EditorCoroutineUtility.html

And then having a progress bar might also be useful:

1 Like

Thank you very much, @eses , that looks exactly like what I am looking for!