I get this exception (see bottom of post) in the Console when I press a button that triggers a time consuming event in an Editor Window.
The button is wrapped in a EditorGUILayout.ScrollViewScope like so:
(var s = new EditorGUILayout.ScrollViewScope(m_ScrollPos))
{
if (GUILayout.Button("Button") == true)
{
// time consuming task
}
}
I’m guessing that the task took too long to complete and that upset the OnGUI’s internal ‘Begin’ / ‘End’ ScrollView. Any ideas on how to fix this or is it just a Unity bug that I have no control over?
This is also thrown from OnGUISafe in my case.
The fix was to call GUIUtility.ExitGUI() after my portion of the GUI was done.
For me it was from a property drawer that was opening a directory or file panel. I just apply my changes to the serializedObject and exit.
Same situation for me under Unity 2021.
But your fix doesn’t work for me. Seems Unity gets buggier with each iteration. Restarting it to be able to Debug, then this… Man.
Thanks for posting. Doesn’t really work for me because GUIUtility.ExitGUI(); just exits all GUI on GameObj it seems.
I’m using Drag&Drop instead of OpenFolderPanel() now. This works flawlessly (yet).
For clarification, I called GUIUtility.ExitGUI() right after my lengthy operation, before the line that throws. As far as I understand, GUIUtility.ExitGUI() just early-outs the GUI.