Hello,
I’m experiencing a bug with the following pseudocode in a custom editor window
void OnGUI()
{
if (GUILayout.Button(“Do Something That Takes 10 minutes”))
{
DoSomethingThatTakes10Minutes();
EditorUtility.DisplayDialog(“Result”, “result text”, “OK”);
}
}
The issue is that as soon as “something that takes 10 minutes” is complete and I click OK from the resulting pop up box, the whole function will run all over again, as if I pressed the button again (even though I didnt click anywhere near it).
Sometimes it only runs once, sometimes it runs multiple times. As you could imagine, I don’t really want to run “something that takes 10 minutes” more than is absolutely necessary so any suggestions for how to fix this would be much appreciated!
Bump - anybody else have experience with this or have a fix for it? It’s popping up again for a new feature and is very frustrating.
Are you doing this long operation synchronously? I would imagine holding up execution of the UI for a while might cause a few issues. It almost sounds like, if it’s taking so long, it isn’t clearing inputs for the following editor loop updates.
I would look at running the process over a number of frames with perhaps editor coroutines.
I’ve seen this error with purely synchronous operations previously, but this latest issue was happening with a heavy parallelized load using Parallel.For. The function being invoked by the Editor is still executing synchronously overall, though. I didn’t know about the Editor Coroutines package, I’ll take a look - thanks for the tip!