Unfocusing Unity Editor when Context Menu is opened in Behavior Graph causes errors

Hello dear Unity developers!

I noticed that I will have the next error if I unfocus to another app while Context Menu in Behavior Graph is opened:

InvalidOperationException: Collection was modified; enumeration operation may not execute.
System.Collections.Generic.HashSet`1+Enumerator[T].MoveNext () (at <378523c1e6ba4db992c5a1e98a5541ae>:0)
Unity.AppUI.Core.AppUIManager.DismissAnyPopups (UnityEngine.UIElements.IPanel panel, Unity.AppUI.Core.DismissType reason) (at ./Library/PackageCache/com.unity.dt.app-ui/Runtime/Core/AppUIManager.cs:312)
Unity.AppUI.Core.AppUI.DismissAnyPopups (UnityEngine.UIElements.IPanel iPanel, Unity.AppUI.Core.DismissType reason) (at ./Library/PackageCache/com.unity.dt.app-ui/Runtime/Core/AppUI.cs:134)
Unity.AppUI.UI.Panel.OnFocusOut (UnityEngine.UIElements.FocusOutEvent evt) (at ./Library/PackageCache/com.unity.dt.app-ui/Runtime/UI/Layouts/Panel.cs:496)
UnityEngine.UIElements.EventCallbackFunctor`1[TEventType].Invoke (UnityEngine.UIElements.EventBase evt) (at <24e165613ea9441aa6d9c8989219aecd>:0)
UnityEngine.UIElements.EventCallbackRegistry+DynamicCallbackList.Invoke (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.BaseVisualElementPanel panel, UnityEngine.UIElements.VisualElement target) (at <24e165613ea9441aa6d9c8989219aecd>:0)
UnityEngine.UIElements.EventDispatchUtilities.HandleEvent_BubbleUpCallbacks (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.BaseVisualElementPanel panel, UnityEngine.UIElements.VisualElement element) (at <24e165613ea9441aa6d9c8989219aecd>:0)
UnityEngine.UIElements.EventDispatchUtilities.HandleEventAcrossPropagationPath (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.BaseVisualElementPanel panel, UnityEngine.UIElements.VisualElement target, System.Boolean isCapturingTarget) (at <24e165613ea9441aa6d9c8989219aecd>:0)
UnityEngine.UIElements.EventDispatchUtilities.PropagateEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.BaseVisualElementPanel panel, UnityEngine.UIElements.VisualElement target, System.Boolean isCapturingTarget) (at <24e165613ea9441aa6d9c8989219aecd>:0)
UnityEngine.UIElements.EventDispatchUtilities.DefaultDispatch (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.BaseVisualElementPanel panel) (at <24e165613ea9441aa6d9c8989219aecd>:0)
UnityEngine.UIElements.EventBase.Dispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at <24e165613ea9441aa6d9c8989219aecd>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.BaseVisualElementPanel panel) (at <24e165613ea9441aa6d9c8989219aecd>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEventQueue () (at <24e165613ea9441aa6d9c8989219aecd>:0)
UnityEngine.UIElements.EventDispatcher.OpenGate () (at <24e165613ea9441aa6d9c8989219aecd>:0)
UnityEngine.UIElements.EventDispatcherGate.Dispose () (at <24e165613ea9441aa6d9c8989219aecd>:0)
UnityEngine.UIElements.FocusController.SwitchFocus (UnityEngine.UIElements.Focusable newFocusedElement, UnityEngine.UIElements.FocusChangeDirection direction, System.Boolean bIsFocusDelegated, UnityEngine.UIElements.DispatchMode dispatchMode) (at <24e165613ea9441aa6d9c8989219aecd>:0)
UnityEngine.UIElements.FocusController.SwitchFocus (UnityEngine.UIElements.Focusable newFocusedElement, System.Boolean bIsFocusDelegated, UnityEngine.UIElements.DispatchMode dispatchMode) (at <24e165613ea9441aa6d9c8989219aecd>:0)
UnityEngine.UIElements.FocusController.Blur (UnityEngine.UIElements.Focusable focusable, System.Boolean bIsFocusDelegated, UnityEngine.UIElements.DispatchMode dispatchMode) (at <24e165613ea9441aa6d9c8989219aecd>:0)
UnityEngine.UIElements.Focusable.Blur () (at <24e165613ea9441aa6d9c8989219aecd>:0)
UnityEngine.UIElements.FocusController.BlurLastFocusedElement () (at <24e165613ea9441aa6d9c8989219aecd>:0)
UnityEngine.UIElements.Panel.Blur () (at <24e165613ea9441aa6d9c8989219aecd>:0)
UnityEditor.UIElements.DefaultEditorWindowBackend.UnityEditor.IEditorWindowBackend.Blurred () (at <d4e36dccc628471eb4f7e7be6057a782>:0)
UnityEditor.HostView.OnLostFocus () (at <9e3a60dbcacc4e77a9c6e1c14064183a>:0)

How to reproduce:

  1. Create a Behavior Graph
  2. Right click on the empty space in the Behavior Graph
  3. Press Add (after that action the Context Menu appears)
  4. Focus on another opened app in your system.
  5. You will get the error

It’s not a big issue, but it’s a bit annoying when debugger is enabled because you need to press Continue in your IDE every time it occurs.

Platform: Windows 10
Behavior Version: 1.0.7
Unity Version: 6000.0.25f1

Thank you!

Thanks for the report, i’ll have a quick play and see if i can repro it.

I can reproduce this, i’ll file a report with the appropriate team.

Thanks,

1 Like